Python Forum
SQL error when using tkinter - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: SQL error when using tkinter (/thread-20963.html)



SQL error when using tkinter - Orsa - Sep-08-2019

Hi,

I am trying to update a MSSQL Datebase from gui that i make but no what ever i do i get an error.
this is how the code looks like:

import tkinter
import pyodbc

conn = pyodbc.connect("Driver={SQL Server Native Client 11.0};"
                      "Server=ORSA\SQLEXPRESS;"
                      "Database=ACDB;"
                      "Trusted_Connection=yes;")

def submit_12():
    cursor = conn.cursor()
    cursor.execute('''
                       UPDATE ACDB.dbo.packages
                       SET speed = spe.get
                       WHERE pack_id = pac.get''')

    conn.commit()


window = tkinter.Tk()
window.title("GUI")
tkinter.Label(window, text="Pack ID").grid(row=0)
pac=tkinter.Entry(window)
pac.grid(row=0, column=1)

tkinter.Label(window, text="Speed").grid(row=1)
spe=tkinter.Entry(window)
spe.grid(row=1, column=1)

tkinter.Label(window, text="start date").grid(row=2)
startdate=tkinter.Entry(window)
startdate.grid(row=2, column=1)

tkinter.Button(window, text = "Quit", command=window.quit).grid(row=3, column=0)
tkinter.Button(window, text = "Submit", command=submit_12).grid(row=3, column=1)


window.mainloop()
this is the errors that i get:
Error:
Exception in Tkinter callback Traceback (most recent call last): File "C:\Program Files (x86)\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__ return self.func(*args) File "C:/Users/OrSa/Desktop/אקדא10000.py", line 15, in submit_12 WHERE pack_id = pac.get''') pyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][SQL Server Native Client 11.0][SQL Server]The multi-part identifier "pac.get" could not be bound. (4104) (SQLExecDirectW)')



RE: SQL error when using tkinter - Larz60+ - Sep-09-2019

The error has nothing to do with tinkter, it's pac.get that's causing the problem.


RE: SQL error when using tkinter - woooee - Sep-09-2019

Search for an SQL tutorial. They all have examples how to select a record from a DB. Also get() is a function.