Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymysql.cursors
- username = "job"
- password = "test"
- connection = pymysql.connect(host='localhost',
- user='root',
- password='',
- db='casus',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor)
- try:
- with connection.cursor() as cursor:
- sql = "SELECT `id`, `username`, `password`, `rank` FROM `users` WHERE `username`=%s AND `password`=%s"
- cursor.execute(sql, (username, password))
- results = cursor.fetchall()
- for row in results:
- ids = row['id']
- username = row['username']
- password = row['password']
- rank = row['rank']
- print(ids, username, password, rank)
- finally:
- connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement