Guest User

Untitled

a guest
Jan 30th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. from tkinter import *
  2. import pymysql.cursors
  3. import pymysqlpool
  4.  
  5.  
  6. # Подключение к БД
  7. connection = pymysql.connect(host='127.0.0.1',
  8. user='root',
  9. password='',
  10. db='python',
  11. charset='utf8mb4',
  12. cursorclass=pymysql.cursors.DictCursor,
  13. autocommit=True)
  14.  
  15.  
  16.  
  17.  
  18.  
  19. def mycon():
  20. text = edit.get()
  21. t1.config(text = text)
  22.  
  23. x=1
  24. while x>1000000:
  25.  
  26. x=x+1
  27.  
  28. try:
  29. with connection.cursor() as cursor:
  30. # Отправка SQL запроса
  31. sql = "INSERT INTO `scaner` (`number`) VALUES (%s)"
  32. cursor.execute(sql, (text))
  33.  
  34. # Сохранение изменения
  35. connection.commit()
  36.  
  37. finally:
  38. print(text)
  39.  
  40.  
  41. if x==1000000:
  42.  
  43. connection.close()
  44.  
  45. win = Tk()
  46. win.geometry('600x300')
  47.  
  48. win.title("Отправлялка")
  49.  
  50. t0 = Label(win, text='Отправим в БД', fg='blue')
  51. t0.config(font=('Verdana', 25))
  52. t0.pack()
  53.  
  54. t1 = Label(win, text='Заставка Текст', fg='blue')
  55. t1.config(font=('Verdana', 16))
  56. t1.pack()
  57.  
  58. edit = Entry (win, width = 20, bg = 'gray')
  59. edit.pack()
  60.  
  61. but = Button(win, text = 'Отправить', command = mycon)
  62. but.pack()
  63.  
  64.  
  65. var=IntVar()
  66. rbutton1=Radiobutton(win,text='Водка: 0.5',variable=var,value=1)
  67. rbutton2=Radiobutton(win,text='Водка: 0.7',variable=var,value=2)
  68. rbutton1.pack()
  69. rbutton2.pack()
  70.  
  71.  
  72.  
  73.  
  74.  
  75. win.mainloop()
Add Comment
Please, Sign In to add comment