Advertisement
Guest User

Untitled

a guest
Mar 5th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. import pymysql.cursors
  2. import pymysqlpool
  3.  
  4. # Connect to the database.
  5. connection = pymysql.connect(host='127.0.0.1',
  6. user='root',
  7. password='',
  8. db='python',
  9. charset='utf8mb4',
  10. cursorclass=pymysql.cursors.DictCursor)
  11. counter = True
  12. x=1
  13. while x < 1000000:
  14. print ("Успешное соединение!")
  15. print ("Введите штрихкод: ")
  16. x=x+1
  17.  
  18. with connection.cursor() as cursor:
  19. sql = "SELECT id, number FROM scaner2 "
  20. cursor.execute(sql)
  21. results = cursor.fetchall()
  22. df = list([number["number"] for number in results])
  23. b2 = input()
  24.  
  25.  
  26. if len(b2) == 0:
  27. print ('Введите код')
  28. elif len(b2) != 0:
  29. cursor.execute("SELECT id FROM scaner2 WHERE number =" + b2+"")
  30. global res
  31. res = cursor.fetchall()
  32. if b2 in df:
  33. fdsd = list(res [0]['id'] for id in res)
  34. print(fdsd)
  35. else:
  36. print ('Код не найден')
  37. print ('Повторите попытку')
  38.  
  39.  
  40.  
  41.  
  42. if x>1000000:
  43. counter=False
  44. connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement