473,732 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sqlite error?

Am I using the ? placeholder wrong in this example?
t = ('hi', 'bye')

self.connection .execute("INSER T INTO Personal (firstName, lastName)
VALUES ?", t)

Traceback (most recent call last):
File "C:\Python25\my scripts\labdb\d bapp.py", line 93, in OnSaveRecord
self.save_to_da tabase(textfiel d_values)
File "C:\Python25\my scripts\labdb\d bapp.py", line 97, in save_to_databas e
self.connection .execute("INSER T INTO Personal (firstName, lastName)
VALUES ?", t)
sqlite3.Operati onalError: near "?": syntax error
Nov 6 '06 #1
5 4004
>self.connectio n.execute("INSE RT INTO Personal (firstName, lastName)
VALUES ?", t)

John,

I'm no expert, but try

self.connection .execute("INSER T INTO Personal (firstName, lastName)
VALUES ?, ?", t)

Nov 6 '06 #2

John Salerno wrote:
Am I using the ? placeholder wrong in this example?
t = ('hi', 'bye')

self.connection .execute("INSER T INTO Personal (firstName, lastName)
VALUES ?", t)

Traceback (most recent call last):
File "C:\Python25\my scripts\labdb\d bapp.py", line 93, in OnSaveRecord
self.save_to_da tabase(textfiel d_values)
File "C:\Python25\my scripts\labdb\d bapp.py", line 97, in save_to_databas e
self.connection .execute("INSER T INTO Personal (firstName, lastName)
VALUES ?", t)
sqlite3.Operati onalError: near "?": syntax error
I believe you're missing the parens around your VALUES to insert. Also,
you need 1 placeholder per argument inserted, not just one for the
entire argument list. Try:

self.connection .execute("INSER T INTO Personal (firstName, lastName)
VALUES (?, ?)", t)

HTH

Nov 6 '06 #3
th*********@gma il.com wrote:
John Salerno wrote:
>Am I using the ? placeholder wrong in this example?
t = ('hi', 'bye')

self.connectio n.execute("INSE RT INTO Personal (firstName, lastName)
VALUES ?", t)

Traceback (most recent call last):
File "C:\Python25\my scripts\labdb\d bapp.py", line 93, in OnSaveRecord
self.save_to_da tabase(textfiel d_values)
File "C:\Python25\my scripts\labdb\d bapp.py", line 97, in save_to_databas e
self.connection .execute("INSER T INTO Personal (firstName, lastName)
VALUES ?", t)
sqlite3.Operat ionalError: near "?": syntax error

I believe you're missing the parens around your VALUES to insert. Also,
you need 1 placeholder per argument inserted, not just one for the
entire argument list. Try:

self.connection .execute("INSER T INTO Personal (firstName, lastName)
VALUES (?, ?)", t)

HTH
Thanks guys. I'll try this. I thought the ? stood for the whole tuple.
Nov 6 '06 #4

John Salerno wrote:
Am I using the ? placeholder wrong in this example?
t = ('hi', 'bye')

self.connection .execute("INSER T INTO Personal (firstName, lastName)
VALUES ?", t)
[snip]
>
Thanks guys. I'll try this. I thought the ? stood for the whole tuple.
Definitely not. You could have a sql command like this -

cur.execute("UP DATE table SET col1 = ?, col2 = ? WHERE col3 = ? AND
col4 = ?",(1,2,3,4) )

The parameters could be scattered throughout the command. Therefore the
substitution is one-for-one from left to right using the values in the
tuple.

Frank Millman

Nov 7 '06 #5
Frank Millman wrote:
Definitely not. You could have a sql command like this -

cur.execute("UP DATE table SET col1 = ?, col2 = ? WHERE col3 = ? AND
col4 = ?",(1,2,3,4) )

The parameters could be scattered throughout the command. Therefore the
substitution is one-for-one from left to right using the values in the
tuple.
Thanks! The example I was looking at in the docs didn't use parentheses,
but I also didn't connect that with the fact that it was only using a
one-tuple! :)
Nov 7 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
8495
by: Greg Miller | last post by:
I have an application that uses sqlite3 to store job/error data. When I log in as a German user the error codes generated are translated into German. The error code text is then stored in the db. When I use the fetchall() to retrieve the data to generate a report I get the following error: Traceback (most recent call last): File "c:\Pest3\Glosser\baseApp\reportGen.py", line 199, in OnGenerateButtonNow self.OnGenerateButton(event)
1
2578
by: David Fowler | last post by:
I'm new to getting in touch with other PHP users/PHP team, so please excuse me if this post is at all inappropriate or in the wrong place. In the current release of PHP (5.1.4) and in the CVS for PHP5.1.* and 5.2.* the SQLite source version only stands at 3.2.8, while the actual realease is now at 3.3.6. What I was wondering is whether or not this could be updated, as there have been numerous bug fixes in the SQLite source in the past 6...
14
2976
by: 7stud | last post by:
Does sqlite come in a mac version? Thanks.
10
7561
by: Luigi | last post by:
Hello all! I'm a newbie in PHP. I have written a short script that tries to update a SQLite database with the user data. It is pretty simple, something like this: <?php $sqlite = sqlite_open("mytest.db", 0666, $sqlite_error);
8
3414
by: Gilles Ganault | last post by:
Hello I need to compile PHP5 with SQLite statically and without PDO. I don't need DB-independence, so it's fine using sqlite_*() functions instead of PDO. 1. I've downloaded, compiled, and installed sqlite.org/sqlite-3.5.4.tar.gz, and... 2. used "--with-sqlite --disable-pdo", but it fails.
3
275
by: Daniel Fetchinson | last post by:
Does Python 2.5.2's embedded SQLite support full text searching? Sqlite itself is not distributed with python. Only a python db api compliant wrapper is part of the python stdlib and as such it is completely independent of the sqlite build. In other words, if your sqlite build supports full text searching you can use it through the python sqlite wrapper (that is part of the stdlib) and if it doesn't then not. This is true for any sqlite...
0
1398
by: Guilherme Polo | last post by:
On Tue, Jul 1, 2008 at 9:51 PM, Joe Goldthwaite <joe@goldthwaites.comwrote: You need sqlite itself (www.sqlite.org) and bindings, pysqlite 2 (http://oss.itsystementwicklung.de/trac/pysqlite/) or aspw (http://code.google.com/p/apsw/) You are confused, yes. The sqlite3 package that comes with python2.5 is actually pysqlite2, which interfaces with sqlite3. Also, sqlite3 and sqlite2 files format are not compatible.
0
2571
by: Joe Goldthwaite | last post by:
Thanks Guilherme. That helped. I guess I was thinking that pysqlite would automatically come with some version of sqlite. The fact that it doesn't is what was causing me to get the strange results. I downloaded the Windows version of the SQLite3.dll. I didn't know where to put it so I first put it in its own directory and tried to register it. That didn't work so I just moved it to the pysqlite directory in site-packages. That did...
20
3970
by: timotoole | last post by:
Hi all, On a (sun) webserver that I use, there is python 2.5.1 installed. I'd like to use sqlite3 with this, however sqlite3 is not installed on the webserver. If I were able to compile sqlite using a sun machine (I normally use linux machines) and place this in my lunix home account would I be able to use python and sqlite? Any thoughts? I know its a bit of a stretch ...
0
9447
Oralloy
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...
1
9235
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,...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6735
isladogs
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...
0
4550
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...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
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
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.