0

I have been getting this error and have stuck a few hours trying to understand what I am doing wrong. I have use this template for successfully importing into sqlite3 many many times in the past.

def TestImport():
   con = sqlite3.connect("test.db")
   con.execute("CREATE TABLE IF NOT EXISTS TestTable(ColA,ColB)")
   data=[('x','y')]
   stmt = "INSERT INTO TestTable VALUES(?,?)"
   con.execute(data,stmt)
   con.commit()
   con.close()

However this time I am getting this error:

ValueError: operation parameter must be str or unicode

here

con.execute(data,stmt)

1 Answer 1

1

It should be

con.execute(stmt, data[0])
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.