0

the program must store these details in a table. I'm new to SQL and would like to know how to insert variables

    c.execute('''INSERT INTO userAcc(name, dob, age) VALUES(%s,%s,%s)'''(name1, dob1, age1))
    conn.commit()
    c.close()
    conn.close()
1
  • Please give a proper error description! Commented Sep 17, 2017 at 21:06

1 Answer 1

2

SQLite does not support the %s syntax as a placeholder (https://docs.python.org/3/library/sqlite3.html). Use question marks instead, and don't forget to insert a comma after the SQL string:

c.execute('''INSERT INTO userAcc(name, genre, artist) VALUES(?,?,?)''', (name1, genre1, artist1))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.