Reputation: 89
im getting this error:
cursor.execute('INSERT INTO COURSE (title) VALUES (?)',(title))
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 11 supplied.
Here is my code:
try:
cursor.execute("""CREATE TABLE COURSE
(course_id INTEGER PRIMARY KEY,
title TEXT)""")
except sql.OperationalError, msg:
print msg
.....
def add_course(title):
try:
cursor.execute('''INSERT INTO COURSE (title) VALUES (?)''',(title))
except sql.OperationalError, msg:
print msg,
.....
add_course('Calculus II')
It seams as if it counts each character as a value, but i dont understand why.. i have many tables and they handle strings (TEXT) types properly. The only difference in my other tables is that they take in more than one value.
Upvotes: 1
Views: 2372
Reputation: 118538
Try passing a tuple:
cursor.execute('''INSERT INTO COURSE (title) VALUES (?)''',(title,))
It's iterating over title.
Upvotes: 3