check_user.py 2.72 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,])
            i=0
            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_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_game("카나리아사"))
print(read_level("카나리아사"))
print(read_country("카나리아사"))
print(read_season("카나리아사"))
print(read_score("카나리아사"))