473,383 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

sqlite query not working

Hopefully this is enough code to reveal the problem. When I run the
program, there are no error messages produced, it's just that the values
I enter don't seem to get put into the database, even though the query
seems to be ok.
def OnSaveRecord(self, event):
textfield_values = []
for tab in self.notebook.GetCurrentPage().GetChildren():
for table in self.get_textfield_ids():
table_values = []
for textfield_id in table:
table_values.append(xrc.XRCCTRL(tab,
textfield_id).GetValue())
textfield_values.append(table_values)
res_id = self.create_id(textfield_values[0][0],
textfield_values[0][2])
for table in textfield_values:
table.insert(0, res_id)
self.save_to_database(textfield_values)

def save_to_database(self, data):
# doesn't work?
self.connection.execute("""INSERT INTO Personal VALUES
(?,?,?,?,?,?,?,?,?,?)""", tuple(data[0]))
Nov 7 '06 #1
7 1628
John Salerno wrote:
Hopefully this is enough code to reveal the problem. When I run the
program, there are no error messages produced, it's just that the values
I enter don't seem to get put into the database, even though the query
seems to be ok.
def OnSaveRecord(self, event):
textfield_values = []
for tab in self.notebook.GetCurrentPage().GetChildren():
for table in self.get_textfield_ids():
table_values = []
for textfield_id in table:
table_values.append(xrc.XRCCTRL(tab,
textfield_id).GetValue())
textfield_values.append(table_values)
res_id = self.create_id(textfield_values[0][0],
textfield_values[0][2])
for table in textfield_values:
table.insert(0, res_id)
self.save_to_database(textfield_values)

def save_to_database(self, data):
# doesn't work?
self.connection.execute("""INSERT INTO Personal VALUES
(?,?,?,?,?,?,?,?,?,?)""", tuple(data[0]))
Have you tried adding a self.connection.commit() to the code? I don't
know whether sqlite is transactional, but if it is then the changes will
disappear without a commit.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Nov 7 '06 #2
Steve Holden wrote:
Have you tried adding a self.connection.commit() to the code? I don't
know whether sqlite is transactional, but if it is then the changes will
disappear without a commit.
Wow, that worked! Now, I know I've done some DB work before (very
similar to this) and never used commit(), so I'm confused but still
grateful! :)

Thanks!
Nov 7 '06 #3
>Have you tried adding a self.connection.commit() to the
>code? I don't know whether sqlite is transactional, but if
it is then the changes will disappear without a commit.

Wow, that worked! Now, I know I've done some DB work before
(very similar to this) and never used commit(), so I'm
confused but still grateful! :)

I tinkered with the mx.ODBC drivers a bit and had a similar
difficulty until I realized that it was configured to *not*
autocommit. At least in the mx.ODBC drivers, you can pass a
param ("clear_auto_commit=1") to the Connect() call to restore
"normal" autocommiting behavior. I can see both sides of the
fence...it's just a hassle to sniff out which DB drivers
autocommit and which don't.

-tkc


Nov 7 '06 #4
Tim Chase wrote:
I tinkered with the mx.ODBC drivers a bit and had a similar
difficulty until I realized that it was configured to *not*
autocommit. At least in the mx.ODBC drivers, you can pass a
param ("clear_auto_commit=1") to the Connect() call to restore
"normal" autocommiting behavior. I can see both sides of the
fence...it's just a hassle to sniff out which DB drivers
autocommit and which don't.
What's really strange is that I'm pretty sure (but can always be wrong)
that I've written SQLite queries just as above, and they were saved to
the DB without a commit() call, so it's not like I was even using a
different system. Ah well, I'm sure there was *something* different
about the two cases! :)
Nov 7 '06 #5

John Salerno wrote:
>Ah well, I'm sure there was *something* different
Are you sure that it's not you were doing SELECT before, as opposed to
INSERT?

rd

Nov 7 '06 #6
BartlebyScrivener wrote:
John Salerno wrote:
>>Ah well, I'm sure there was *something* different

Are you sure that it's not you were doing SELECT before, as opposed to
INSERT?
Perhaps. It might have been that I used the INSERT statement on the
sqlite command line, then used SELECT in Python, and got it all mixed up
in my head. :)
Nov 8 '06 #7
Dennis Lee Bieber wrote:
The other thing to consider is that, if you were testing using a
single cursor, and single session, the database would have shown you
uncommitted changes. It wouldn't have been until you closed the
cursor/connection without a commit that the DBMS would have tossed them
-- a select would still retrieve your uncommited changes during that
transaction.
Good point, and I wouldn't be surprised if I had done that too! Working
with databases in Python (as opposed to direct command line queries) is
fairly new to me, so who knows what crazy things I tried to do. :)
Nov 8 '06 #8

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

Similar topics

1
by: Digital Fart | last post by:
hi I want to wrap the access to a sqlite database in an object. So i can create multiple instances of this wrapper with base code to get data out of the sqlite database. But i want to make...
2
by: Christian Stooker | last post by:
Part one: ====== Hi ! I want to use SQLite database like the FireBird database: with big isolation level. What's that meaning ? I have an application that periodically check some input...
12
by: John Salerno | last post by:
I've been looking around and reading, and I have a few more questions about SQLite in particular, as it relates to Python. 1. What is the current module to use for sqlite? sqlite3? or is that not...
4
by: Jim Carlock | last post by:
I added the following lines to PHP.INI. extension=php_pdo.dll extension=php_pdo_sqlite.dll extension=php_sqlite.dll specifically in that order. I noticed the extensions getting loaded are...
10
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 =...
20
by: Rob Stevens | last post by:
Can someone tell me how to import the sqlite3.dll file into c#. I am pretty new to this, and I want to use sqlite. The problem is I don't have a clue on how to import the dll file so i can call...
6
by: Rob Stevens | last post by:
I have been trying to find some working examples of working with this DB, but I can't seem to find anything at all. If I do find examples, its all referring to the command line program that...
3
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...
0
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.