Advertisement
Guest User

Untitled

a guest
Apr 16th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import pymysql.cursors
  2.  
  3. username = "job"
  4. password = "test"
  5.  
  6. connection = pymysql.connect(host='localhost',
  7. user='root',
  8. password='',
  9. db='casus',
  10. charset='utf8mb4',
  11. cursorclass=pymysql.cursors.DictCursor)
  12.  
  13. try:
  14. with connection.cursor() as cursor:
  15. sql = "SELECT `id`, `username`, `password`, `rank` FROM `users` WHERE `username`=%s AND `password`=%s"
  16. cursor.execute(sql, (username, password))
  17.  
  18. results = cursor.fetchall()
  19. for row in results:
  20. ids = row['id']
  21. username = row['username']
  22. password = row['password']
  23. rank = row['rank']
  24. print(ids, username, password, rank)
  25. finally:
  26. connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement