sqlite error?

Frank Millman frank at chagford.com
Tue Nov 7 00:20:15 EST 2006


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)
> >>
[snip]
>
> Thanks guys. I'll try this. I thought the ? stood for the whole tuple.

Definitely not. You could have a sql command like this -

cur.execute("UPDATE table SET col1 = ?, col2 = ? WHERE col3 = ? AND
col4 = ?",(1,2,3,4))

The parameters could be scattered throughout the command. Therefore the
substitution is one-for-one from left to right using the values in the
tuple.

Frank Millman




More information about the Python-list mailing list