Ich bin zurück mit einigen Schwierigkeiten ._.
Kann mir jemand helfen? Ich habe Probleme, wenn ich einige Daten in meine Datenbank von Tkinter Entry(Widgets)
legen möchte.
Ich habe Tabelle "Buch" in meiner Datenbank, ich möchte einige Daten von tkinter
zu meinem Tisch "Buch".
Ich benutze bereits get
aber ich bekomme nichts in meinen Programmen kann mir jemand dafür helfen?Erhalte Daten von Tkinter Python zur Datenbank MySQL
Vielen Dank. oh ja, das ist mein Skript ist :)
from tkinter import *
import mysql.connector as mc
import tkinter.messagebox as tm
def put(*args):
e_code = i_code.get()
e_name = i_name.get()
e_price = i_price.get()
conn = mc.connect(user="root", password="mypassword", host="localhost", database="book_test")
cur = conn.cursor()
cur.execute("insert into book(book_code, book_name, book_price) values('"+e_code+"', '"+e_name+"', '"+e_price+"')")
conn.close()
root = Tk()
root.title("GET DATA")
mainframe = Frame(root)
mainframe.pack()
i_code = IntVar()
i_name = StringVar()
i_price = IntVar()
codeEntry = Entry(mainframe, width=7, textvariable=i_code)
nameEntry = Entry(mainframe, width=7, textvariable=i_name)
priceEntry = Entry(mainframe, width=7, textvariable=i_price)
codeEntry.grid(row=0, column=1)
nameEntry.grid(row=1, column=1)
priceEntry.grid(row=2, column=1)
Label(mainframe, text='Book Code').grid(row=0, column=0)
Label(mainframe, text='Book Name').grid(row=1, column=0)
Label(mainframe, text='Book Price').grid(row=2, column=0)
Button(mainframe, text="Insert", command=put).grid(row=3, column=1)
root.mainloop()
ich diese Fehlermeldung erhalten, kann mir jemand helfen? oder gib mir den Hinweis hahaha ._.
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.5/tkinter/__init__.py", line 1553, in __call__return self.func(*args)
File "/home/oncom/PycharmProjects/guiProject/fkinggetdata.py", line 13, in put
cur.execute("insert into book(book_code, book_name, book_price) values('"+e_code+"', '"+e_name+"', '"+e_price+"')")
TypeError: Can't convert 'int' object to str implicitly
Es ist nicht klar, was Ihr Problem ist. Erhalten Sie eine Fehlermeldung? – scotty3785
warten, ich werde Versuch und Ausnahme verbergen ..... – Oncom
@ scotty3785 Kumpel Sie können meine redigierte Frage für mehr Informationen überprüfen hehehe -_- danke vor – Oncom