vendredi 24 juillet 2015

Error while saving Tkinter Entry data into SQL

The idea is a program for a Library to add the information about the borrowed books. I have some Tkinter entries and their variables

nombre1 = StringVar()
libro1 = StringVar()
codigo1 = StringVar()

cajaNom = Entry(root,textvariable=nombre1).place(x=150,y=30)
cajaLib = Entry(root,textvariable=libro1).place(x=150,y=60)
cajaCod = Entry(root,textvariable=codigo1).place(x=150,y=90)

It works fine, however, when I want to save these into SQLdb the error apprears. USING SQLITE3

def guardar():
nombre2 = nombre1.get()
libro2 = libro1.get()
codigo2 = codigo1.get()


#Connect SQL
conn = sqlite3.connect('biblioteca.db')
cs = conn.cursor()

#Save in Tables
save = '''INSERT INTO Prestamos (Nombre, Libro, Codigo) 
        VALUES (%s, %s, %s);''' % (nombre2, codigo2, libro2)
cs.execute(save,)

The error is [...] in guardar cs.execute(save,) OperationalError: no such column: (whatever I put in the entry)

It looks like it takes the entry as a column name, however I can't find the problem in the INSERT INTO code

Sorry for the bad English

Aucun commentaire:

Enregistrer un commentaire