Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pysqlite2.dbapi2.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are -1 supplied.

13 views
Skip to first unread message

F. GEIGER

unread,
May 17, 2005, 3:10:11 PM5/17/05
to
Im on Python 2.3.4, using pysqlite 2.0.0 (final).

When I try to execute

self._dbc.execute(q, data)

where q is 'select count(*) from Difflets ' and date is None

I get the following exception:

pysqlite2.dbapi2.ProgrammingError: Incorrect number of bindings supplied.
The current statement uses 0, and there are -1 supplied.

Any ideas?

Many thanks in advance and kind regards
Franz GEIGER

F. GEIGER

unread,
May 17, 2005, 3:17:13 PM5/17/05
to
Arrgh, sorry for that post!

self._dbc.execute(q, data)

where data is None, works with MySQL. For SQLite I have to write

if data is not None:
self._dbc.execute(q, data)
else:
self._dbc.execute(q)

Sorry again,
Franz GEIGER

"F. GEIGER" <f.ge...@vol.at> schrieb im Newsbeitrag
news:d6dfi8$ck8$1...@news.hispeed.ch...

Gerhard Häring

unread,
May 17, 2005, 5:05:16 PM5/17/05
to pytho...@python.org, F. GEIGER
F. GEIGER wrote:
> Arrgh, sorry for that post!
>
> self._dbc.execute(q, data)
>
> where data is None, works with MySQL. For SQLite I have to write
>
> if data is not None:
> self._dbc.execute(q, data)
> else:
> self._dbc.execute(q)

No, you have to write:

self._dbc.execute(q, (data,))

in both drivers.

i. e. the second parameter to execute *must* be a sequence. Some drivers
(maybe MySQLdb, too) automatically correct the wrong call and transform a:

execute(sql, single_param)

into a

execute(sql, (single_param,))

for you if they notice that "!PySequence_Check(single_param)".

pysqlite 2 does not do this.

HTH,

-- Gerhard

F. GEIGER

unread,
May 18, 2005, 11:46:40 AM5/18/05
to
Thank you Gerhard,

"Gerhard Häring" <g...@ghaering.de> schrieb im Newsbeitrag
news:mailman.117.1116363...@python.org...


> F. GEIGER wrote:
> > Arrgh, sorry for that post!
> >
> > self._dbc.execute(q, data)
> >
> > where data is None, works with MySQL. For SQLite I have to write
> >
> > if data is not None:
> > self._dbc.execute(q, data)
> > else:
> > self._dbc.execute(q)
>
> No, you have to write:
>
> self._dbc.execute(q, (data,))
>
> in both drivers.
>
> i. e. the second parameter to execute *must* be a sequence. Some drivers
> (maybe MySQLdb, too) automatically correct the wrong call and transform a:
>

Okay, that makes sense.


> execute(sql, single_param)
>
> into a
>
> execute(sql, (single_param,))
>
> for you if they notice that "!PySequence_Check(single_param)".
>
> pysqlite 2 does not do this.
>
> HTH,
>
> -- Gerhard

Many thanks again
Franz


0 new messages