Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymysql.cursors
- import pymysqlpool
- # Connect to the database.
- connection = pymysql.connect(host='127.0.0.1',
- user='root',
- password='',
- db='python',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor)
- counter = True
- x=1
- while x < 1000000:
- print ("Успешное соединение!")
- print ("Введите штрихкод: ")
- x=x+1
- with connection.cursor() as cursor:
- sql = "SELECT id, number FROM scaner2 "
- cursor.execute(sql)
- results = cursor.fetchall()
- df = list([number["number"] for number in results])
- b2 = input()
- if len(b2) == 0:
- print ('Введите код')
- elif len(b2) != 0:
- cursor.execute("SELECT id FROM scaner2 WHERE number =" + b2+"")
- global res
- res = cursor.fetchall()
- if b2 in df:
- fdsd = list(res [0]['id'] for id in res)
- print(fdsd)
- else:
- print ('Код не найден')
- print ('Повторите попытку')
- if x>1000000:
- counter=False
- connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement