Home > front end >  Table has no column named tkinter sqlite
Table has no column named tkinter sqlite

Time:05-30

i'm trying to add 'componente' to my sql column 'componenti' in the table but, when i try to do it,i get this error:"table (table_name) has no column named (column_name)". I think i used the correct sintax so i can't figure out why. Im sure that the database name, which i connected to, is right. Thanks in advance. Heres the part of code i'm talking about.

#it's sql lite btw
def inserisciDati():
    global tabellaNuova
    #immagazzinare il valore di ogni componente
    valuesComponenti = list(componente.get() for componente in contentComponenti)
    #immagazzinare il prezzo di ogni componente
    valuesPrezzi = (prezzo.get() for prezzo in contentPrezzi)
    #connettersi al database
    conn = sqlite3.connect("Clienti.db")
    c = conn.cursor()
    tabellaNuova = str(inputNome.get())
    nomiTabelle.append(tabellaNuova)
    #crea tabella sql
    c.execute("""
        CREATE TABLE IF NOT EXISTS """   tabellaNuova   """(
            componenti VARCHAR(50)
        );
    """)
    #inserire componenti nella nuova tabella
    for componente in valuesComponenti:
        c.execute("INSERT INTO "   tabellaNuova   " VALUES ('"   componente   "');")

CodePudding user response:

You are missing the table column that you are inserting into from what I can tell.

#inserire componenti nella nuova tabella
    for componente in valuesComponenti:
        c.execute("INSERT INTO "   tabellaNuova   "(componenti) VALUES ('"   componente   "');")
  • Related