Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymysql.cursors
- # Connect to the database.
- connection = pymysql.connect(host='127.0.0.1',
- user='root',
- password='',
- db='python',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor)
- print ("connect successful!!")
- try:
- with connection.cursor() as cursor:
- # SQL
- sql = "SELECT id, number FROM scaner2 "
- # Execute query.
- bbb = cursor.execute(sql)
- results = cursor.fetchall()
- df = list([number["number"] for number in results])
- print ("cursor.description: ", df)
- b2 = str(input())
- if b2 in df:
- w2 = "SELECT id FROM scaner2 WHERE number = srt(b2)"
- cursor.execute(w2)
- res = cursor.fetchall()
- print(res)
- else:
- print ('Код не найден')
- finally:
- # Close connection.
- connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement