Question

I have Python code:

cursor.execute('INSERT INTO users (email, password, password_hint, state, last_saved) VALUES (?, ?, ?, ?, DATETIME("now"));',
((get_cgi('email'),), (password,), (get_cgi('password_hint'),), (get_cgi('current'),)))

This is generating the following error:

Traceback (most recent call last):
  File "./create_account.cgi", line 73, in <module>
    ((get_cgi('email'),), (password,), (get_cgi('password_hint'),), (get_cgi('current'),)))
sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.

A debug log of get_cgi('email') placed just before the crash returns the expected email address, so I would expect that the column 'email' of type TEXT should be able to deal with it.

What is SQLite3 complaining about? Have I missed some detail of DB-API2?

Was it helpful?

Solution

I'm not sure why you're creating all those nested tuples, but removing them should make things work better; a tuple is not supported to insert (at least in this way) into a text field.

cursor.execute(
    'INSERT INTO users (email, password, password_hint, state, last_saved) ' +
    'VALUES (?, ?, ?, ?, DATETIME("now"));',
    (get_cgi('email'), password, get_cgi('password_hint'), get_cgi('current')))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top