Python Forum
SQL error when using tkinter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQL error when using tkinter
#1
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)')
Reply
#2
The error has nothing to do with tinkter, it's pac.get that's causing the problem.
Reply
#3
Search for an SQL tutorial. They all have examples how to select a record from a DB. Also get() is a function.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020