1

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.

2
  • sql refers to sqlite3.. i did "import sqlite3 as sql" Commented Apr 10, 2011 at 4:49
  • I suppose the data type is passed as character array. Commented Apr 10, 2011 at 4:55

1 Answer 1

3

Try passing a tuple:

cursor.execute('''INSERT INTO COURSE (title) VALUES (?)''',(title,)) 

It's iterating over title.

Sign up to request clarification or add additional context in comments.

1 Comment

That worked!! Thank You!! i've been killing myself over this for hours

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.