Python sqlite TypeError: not all arguments converted during string formatting
juni 19, 2010
I just spent half an hour trying to get python to insert a bunch of strings into my sqlite db and I kept getting this typeerror. So I started my google fu and got to a bunch of unsolved forum posts.
I found the solution myself. You see, I had been doing this:
self.db.execute(‘INSERT INTO bookmarks(a,b,c) VALUES(?, ?, ?)’%(a,b,c))
(with correct placeholders for sqlite3: ‘?’), when I should have sent the tuple as a second argument to the execute function:
self.db.execute(‘INSERT INTO bookmarks(a,b,c) VALUES(?, ?, ?)’, (a,b,c))
So stupid. Might help someone in the future.