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 3 5382
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Darren Dale |
last post by:
Hello,
def test(data):
i = ? This is the line I have trouble with
if i==1: return data
else: return data
a,b,c,d = test()
|
by: F. GEIGER |
last post by:
I've troubles to let my app take off using pysqlite.
What I wonder most for now is that "pysqlite2.dbapi2.OperationalError:
cannot commit transaction - SQL statements in progress" when I do this:...
|
by: Steven D'Aprano |
last post by:
I'm trying to keep an open mind, but I am perplexed
about something in Python that strikes me as a poor design.
py> def func(a,b):
py> print a,b
py> func(1)
Traceback (most recent call...
|
by: Michele Simionato |
last post by:
An easy question, but I don't find the answer in the docs :-(
I have a sqlite3 database containing accented characters (latin-1).
How do I set the right encoding? For instance if I do this:
#-*-...
|
by: Mark Hansen |
last post by:
I'm trying to convert some schema creation scripts that were
used on MS SQL Server to DB2 (v8.2) and have a problem with
the following select statement (snippet) used for a view:
SELECT
col1,...
|
by: Ben Pfaff |
last post by:
One issue that comes up fairly often around here is the poor
quality of the pseudo-random number generators supplied with many
C implementations. As a result, we have to recommend things like...
|
by: Einar |
last post by:
Hi,
I wonder if there is a nice bit twiddling hack to compare a large
number of variables?
If you first store them in an array, you can do:
for (i = 0; i < n; i++) {
if (array != value) {...
|
by: Brad |
last post by:
I have written some code to manipulate data/records in a MASTER (order
header) and DETAIL (order details) tables.
What I have written is too extensive to post but essentially trying to:
1....
|
by: Thomas Bartkus |
last post by:
Does anyone use emacs together with both WordStar key bindings and python
mode? I'm afraid that Wordstar editing key commands are burned R/O into my
knuckles!
I would like to play with emacs...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |