sqlite error?
John Salerno
johnjsal at NOSPAMgmail.com
Mon Nov 6 16:56:41 EST 2006
thunderfoot at gmail.com wrote:
> John Salerno wrote:
>> Am I using the ? placeholder wrong in this example?
>>
>>
>> t = ('hi', 'bye')
>>
>> self.connection.execute("INSERT INTO Personal (firstName, lastName)
>> VALUES ?", t)
>>
>>
>>
>> Traceback (most recent call last):
>> File "C:\Python25\myscripts\labdb\dbapp.py", line 93, in OnSaveRecord
>> self.save_to_database(textfield_values)
>> File "C:\Python25\myscripts\labdb\dbapp.py", line 97, in save_to_database
>> self.connection.execute("INSERT INTO Personal (firstName, lastName)
>> VALUES ?", t)
>> sqlite3.OperationalError: near "?": syntax error
>
> I believe you're missing the parens around your VALUES to insert. Also,
> you need 1 placeholder per argument inserted, not just one for the
> entire argument list. Try:
>
> self.connection.execute("INSERT INTO Personal (firstName, lastName)
> VALUES (?, ?)", t)
>
> HTH
>
Thanks guys. I'll try this. I thought the ? stood for the whole tuple.
More information about the Python-list
mailing list