Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import pymysql.cursors
- import pymysqlpool
- # Подключение к БД
- connection = pymysql.connect(host='127.0.0.1',
- user='root',
- password='',
- db='python',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor,
- autocommit=True)
- def mycon():
- text = edit.get()
- t1.config(text = text)
- x=1
- while x>1000000:
- x=x+1
- try:
- with connection.cursor() as cursor:
- # Отправка SQL запроса
- sql = "INSERT INTO `scaner` (`number`) VALUES (%s)"
- cursor.execute(sql, (text))
- # Сохранение изменения
- connection.commit()
- finally:
- print(text)
- if x==1000000:
- connection.close()
- win = Tk()
- win.geometry('600x300')
- win.title("Отправлялка")
- t0 = Label(win, text='Отправим в БД', fg='blue')
- t0.config(font=('Verdana', 25))
- t0.pack()
- t1 = Label(win, text='Заставка Текст', fg='blue')
- t1.config(font=('Verdana', 16))
- t1.pack()
- edit = Entry (win, width = 20, bg = 'gray')
- edit.pack()
- but = Button(win, text = 'Отправить', command = mycon)
- but.pack()
- var=IntVar()
- rbutton1=Radiobutton(win,text='Водка: 0.5',variable=var,value=1)
- rbutton2=Radiobutton(win,text='Водка: 0.7',variable=var,value=2)
- rbutton1.pack()
- rbutton2.pack()
- win.mainloop()
Add Comment
Please, Sign In to add comment