Im on Python 2.3.4, using pysqlite 2.0.0 (final).
When I try to execute
self._dbc.execu te(q, data)
where q is 'select count(*) from Difflets ' and date is None
I get the following exception:
pysqlite2.dbapi 2.ProgrammingEr ror: 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 5406
Arrgh, sorry for that post!
self._dbc.execu te(q, data)
where data is None, works with MySQL. For SQLite I have to write
if data is not None:
self._dbc.execu te(q, data)
else:
self._dbc.execu te(q)
Sorry again,
Franz GEIGER
"F. GEIGER" <f.******@vol.a t> 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.execu te(q, data)
where q is 'select count(*) from Difflets ' and date is None
I get the following exception:
pysqlite2.dbapi 2.ProgrammingEr ror: 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.execu te(q, data)
where data is None, works with MySQL. For SQLite I have to write
if data is not None: self._dbc.execu te(q, data) else: self._dbc.execu te(q)
No, you have to write:
self._dbc.execu te(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_Ch eck(single_para m)".
pysqlite 2 does not do this.
HTH,
-- Gerhard
Thank you Gerhard,
"Gerhard Häring" <gh@ghaering.de > schrieb im Newsbeitrag
news:ma******** *************** **************@ python.org... F. GEIGER wrote: Arrgh, sorry for that post!
self._dbc.execu te(q, data)
where data is None, works with MySQL. For SQLite I have to write
if data is not None: self._dbc.execu te(q, data) else: self._dbc.execu te(q) No, you have to write:
self._dbc.execu te(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_Ch eck(single_para m)".
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:
t = time.time()
n = len(self)
while len(self):
del self
self.commit()
|
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 last):
File "<stdin>", line 1, in ?
TypeError: func() takes exactly 2 arguments (1 given)
|
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:
#-*- encoding: latin-1 -*-
from pysqlite2 import dbapi2 as sqlite
import os
DBFILE="/tmp/example.db"
|
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,
col2,
timestamp-col1,
TO_CHAR(timestamp-col1, 'HH24')
FROM ...
| |
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
using the high-order bits returned by rand() instead of the
low-order bits, avoiding using rand() for anything that wants
decently random numbers, not using rand() if you want more than
approx. UINT_MAX total different sequences, and so on.
So I...
|
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) {
/* array differs from value, do something*/
|
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. Assign to a datarow (dr1) the first record of the MASTER table
2. Assign to another datarow (dr2) the second record of the MASTER table
3. If dr1.field1 = dr2.field1, then proceed, otherwise do stop
4. Assign to a third datarow (dr3) the first record...
|
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 for Python editing but I'm having (2)
problems.
1) When I load a .py file, emacs automatically overrides my wordstar-mode
with python-mode, forcing all the keybindings back to emacs native keys.
Why?
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |