469,323 Members | 1,560 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

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

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

Jul 19 '05 #1
3 5113
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.******@vol.at> schrieb im Newsbeitrag
news:d6**********@news.hispeed.ch...
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

Jul 19 '05 #2
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
Jul 19 '05 #3
Thank you Gerhard,

"Gerhard Häring" <gh@ghaering.de> schrieb im Newsbeitrag
news:ma*************************************@pytho n.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
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

66 posts views Thread by Darren Dale | last post: by
2 posts views Thread by Steven D'Aprano | last post: by
5 posts views Thread by Michele Simionato | last post: by
70 posts views Thread by Ben Pfaff | last post: by
122 posts views Thread by Einar | last post: by
9 posts views Thread by Brad | last post: by
12 posts views Thread by Thomas Bartkus | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.