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.
-
sql refers to sqlite3.. i did "import sqlite3 as sql"Alex– Alex2011年04月10日 04:49:23 +00:00Commented Apr 10, 2011 at 4:49
-
I suppose the data type is passed as character array.billygoat– billygoat2011年04月10日 04:55:06 +00:00Commented Apr 10, 2011 at 4:55
1 Answer 1
Try passing a tuple:
cursor.execute('''INSERT INTO COURSE (title) VALUES (?)''',(title,))
It's iterating over title.
answered Apr 10, 2011 at 4:53
Yuji 'Tomita' Tomita
119k32 gold badges287 silver badges247 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Alex
That worked!! Thank You!! i've been killing myself over this for hours
default