check_user.py 4.65 KB
import pymysql
def select(user_name):
    conn = pymysql.connect(host='localhost', user='root', password="!!fnsldkwjsrl11", db="project_troll", charset='utf8')
    check=0
    try:
        with conn.cursor() as curs:
            sql = "select name from user_info"
            curs.execute(sql)
            rs = curs.fetchall()
            for row in rs:
                if user_name in row:
                    check=1
    finally:
        conn.close()
    return check
def read_level(user_name):
    conn = pymysql.connect(host='localhost', user='root', password="!!fnsldkwjsrl11", db="project_troll", charset='utf8')
    try:
        with conn.cursor() as curs:
            sql ="select level from user_info where name=%s"
            curs.execute(sql,[user_name,])
            for rs in curs.fetchall():
                temp=rs[0]
    finally:
        conn.close()
    return temp
def read_score(user_name):
    conn = pymysql.connect(host='localhost', user='root', password="!!fnsldkwjsrl11", db="project_troll", charset='utf8')
    try:
        with conn.cursor() as curs:
            sql ="select opscore from analysis_info where name=%s"
            curs.execute(sql,[user_name,])
            for rs in curs.fetchall():
                temp=rs[0]
    finally:
        conn.close()
    return temp
def read_game(user_name):
    conn = pymysql.connect(host='localhost', user='root', password="!!fnsldkwjsrl11", db="project_troll", charset='utf8')
    try:
        with conn.cursor() as curs:
            curs.execute("select * from game_info where name=%s",[user_name,])
            for rs in curs.fetchall():
                temp=rs
        
    finally:
        conn.close()
    lst=list(temp)
    return lst[1],lst[2],lst[3],lst[4],lst[5]
def read_kill(user_name):
    conn = pymysql.connect(host='localhost', user='root', password="!!fnsldkwjsrl11", db="project_troll", charset='utf8')
    try:
        with conn.cursor() as curs:
            curs.execute("select kill_cs from game_info where name=%s",[user_name,])
            for rs in curs.fetchall():
                temp=rs[0]
        
    finally:
        conn.close()
    return temp
def read_view(user_name):
    conn = pymysql.connect(host='localhost', user='root', password="!!fnsldkwjsrl11", db="project_troll", charset='utf8')
    try:
        with conn.cursor() as curs:
            curs.execute("select view_score from game_info where name=%s",[user_name,])
            for rs in curs.fetchall():
                temp=rs[0]
        
    finally:
        conn.close()
    return temp
def read_cs(user_name):
    conn = pymysql.connect(host='localhost', user='root', password="!!fnsldkwjsrl11", db="project_troll", charset='utf8')
    try:
        with conn.cursor() as curs:
            curs.execute("select cs from game_info where name=%s",[user_name,])
            for rs in curs.fetchall():
                temp=rs[0]
        
    finally:
        conn.close()
    return temp
def read_as(user_name):
    conn = pymysql.connect(host='localhost', user='root', password="!!fnsldkwjsrl11", db="project_troll", charset='utf8')
    try:
        with conn.cursor() as curs:
            curs.execute("select assist from game_info where name=%s",[user_name,])
            for rs in curs.fetchall():
                temp=rs[0]
        
    finally:
        conn.close()
    return temp
def read_death(user_name):
    conn = pymysql.connect(host='localhost', user='root', password="!!fnsldkwjsrl11", db="project_troll", charset='utf8')
    try:
        with conn.cursor() as curs:
            curs.execute("select death from game_info where name=%s",[user_name,])
            for rs in curs.fetchall():
                temp=rs[0]
        
    finally:
        conn.close()
    return temp
def read_season(user_name):
    conn = pymysql.connect(host='localhost', user='root', password="!!fnsldkwjsrl11", db="project_troll", charset='utf8')
    try:
        with conn.cursor() as curs:
            curs.execute("select season from match_info where name=%s",[user_name,])
            for i in curs.fetchall():
                temp=i[0]
                break
    finally:
        conn.close()
    return temp
def read_country(user_name):
    conn = pymysql.connect(host='localhost', user='root', password="!!fnsldkwjsrl11", db="project_troll", charset='utf8')
    try:
        with conn.cursor() as curs:
            curs.execute("select country from match_info where name=%s",[user_name,])

            for i in curs.fetchall():
                temp=i[0]
                break
    finally:
        conn.close()
    return temp
print(read_as("카나리아사"))
print(read_kill("카나리아사"))
print(read_cs("카나리아사"))
print(read_death("카나리아사"))
print(read_view("카나리아사"))