pysqlite - simple problem

John Machin sjmachin at lexicon.net
Fri Sep 1 10:34:37 CEST 2006


Fredrik Lundh wrote:
> John Machin wrote:
> >> So this has to be something stupidly simple... but for the life of me I
> >> can't see it.
> >
> > With the '?' paramstyle, the 2nd arg to cursor.execute() should be a
> > *sequence* (typically a tuple) of the values that you are inserting.
> >
> > Tty this:
> > cur.execute("INSERT INTO foo (id) VALUES (?)", (num, ))
> >
> > This is standard Python DBAPI stuff - you would probably get a similar
> > response from other gadgets e.g. mySQLdb -- IOW it's not specific to
> > pysqlite.
>
> that mistake gives an entirely different error message, at least under 2.2.0
> (which is the version shipped with 2.5):
>

You're right. I didn't spot that the OP may be using an antique:

    File "/usr/lib/python2.4/site-packages/sqlite/main.py"

So the advice has to be augmented:
1. Update to latest pysqlite2 (which BTW is a later version that that
shipped with Python 2.5, just to add some confusion)
2. Pass values as a sequence

Cheers,
John




More information about the Python-list mailing list