473,700 Members | 2,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[pysqlite] pysqlite2.dbapi 2.OperationalEr ror: cannot commit transaction - SQL statements in progress

I've troubles to let my app take off using pysqlite.

What I wonder most for now is that "pysqlite2.dbap i2.OperationalE rror:
cannot commit transaction - SQL statements in progress" when I do this:

t = time.time()
n = len(self)
while len(self):
del self[0]
print "%d items deleted in %.3f secs. " % (n, time.time() - t)

self is of class DbTable which lets db tables be used like ordinary Python
objects (after an idea of Scott Scriven):

def __len__(self):
self._query_("s elect count(*) from %s %s" % (self._name,
self._whereClau se))
r = int(self._dbc.f etchone()[0])
return r


def __delitem__(sel f, i):
'''Enables you to remove rows this way: del movies[58]
q = "select %s from %s %s %s limit %s, 1" % (self._nameOfId Col,
self._name, self._whereClau se, self._orderClau se, i)
rid = self._dbc.fetch one()[0]
q = "delete from %s where %s='%s'" % (self._name, self._nameOfIdC ol,

So it boils down to SELECT and DELETE statements called in a loop. After
that a commit is made.

What does pysqlite try to tell me here?
Kind regards
PS.: I use pysqlite 2.0.1 on Python 2.3.4
Jul 19 '05 #1
1 2817
On Wed, May 18, 2005 at 09:41:39PM +0200, F. GEIGER wrote:
I've troubles to let my app take off using pysqlite.

What I wonder most for now is that "pysqlite2.dbap i2.OperationalE rror:
cannot commit transaction - SQL statements in progress" when I do this:

Urgh! I would have preferred simplified demo code. But after a little
thinking, I guessed right.

pysqlite 2 currently has problems doing .commit() .rollback() on the
connection object after a cur.execute("se lect ...") in a few cases.

I know why and I will fix it in 2.0.2 (originally only MacOS X fixes
planned) or if it takes longer to test, in 2.0.3.

Current workarounds:

- don't commit/rollback after SELECT. It doesn't make much sense anyway.
.commit()/.rollback() after your DML statements instead

- Use fetchall()[0] for fetching single rows instead of fetchone() for
queries like your SELECT COUNT.

-- Gerhard
Gerhard Häring - gh@ghaering.de - Python, web & database development

Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFCjFjddIO 4ozGCH14RAkqpAJ 4m2Q3fh/Ta4pFm/v6mw45qBvJI/ACaA/2e

Jul 19 '05 #2

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

Similar topics

by: F. GEIGER | last post by:
In my wxPython-app a part of it gathers data, when a button is pressed, and stores it into a db. The GUI part should display the stuff being stored in the db. When both parts work on the same connection, I get "SQL statements in progress errors". Seems ok to me, you can't do that. So, next step: Both parts get a separate connection. Now I get "Database locked" errors. Hmm, yes, it's GUI stuff after all, being all in the same
by: bapolis | last post by:
Hello, I'm getting the following error: pysqlite2.dbapi2.OperationalError: no such table: tbl1 Here's my code: from pysqlite2 import dbapi2 as sqlite con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_COLNAMES)
by: Rob Cowie | last post by:
Hi all, I'm having difficulty installing pysqlite 2.1.3 on Mac OS X 10.4.4 There are some notes on the pysqlite wiki regarding modification of the setup.py script and I've followed them to no avail. Build and install appear to go smoothly but attempting to run the tests from the python interpreter fails. Likewise any attempt to utilise pysqlite2 in a python script fails.
by: Michael Husmann | last post by:
After upgrading from pysqlite 2.0.5 to pysqlite 2.3.0 writing into a sqlite database increases memory consumption heavily. A similar program with Ruby and sqlite-ruby 1.1.0 does not affect memory consumption at all. Here a short example: ------------------------------- #!/usr/bin/env python import os
by: rdrink | last post by:
I am just getting into pysqlite (with a fair amount of Python and MySQL experience behind me) and have coded a simple test case to try to get the hang of things... yet have run into a 'stock simple' problem... I can create a database 'test.db', add a table 'foo' (which BTW I repeatedly DROP on each run) with one INTGER column 'id', and can insert data into with: cur.execute("INSERT INTO foo (id) VALUES (200)") con.commit()
by: Nader Emami | last post by:
I have installed "TurboGears" and I would install 'pysqlite' also. I am a user on a Linux machine. If I try to install the 'pysqlite' with 'easy_install' tool I get the next error message. The error message is longer than what I send here. % easy_install pysqlite Searching for pysqlite Reading http://cheeseshop.python.org/pypi/pysqlite/ Reading http://pysqlite.org/
by: =?ISO-8859-1?Q?Gerhard_H=E4ring?= | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 pysqlite 2.5.0 released ======================= I'm pleased to announce the availability of pysqlite 2.5.0. This is a release with major new features. Go to http://pysqlite.org/ for downloads, online documentation and
by: Astley Le Jasper | last post by:
I've been getting errors recently when using pysqlite. I've declared the table columns as real numbers to 2 decimal places (I'm dealing with money), but when doing division on two numbers that happen to have no decimal fractions, the results through pysqlite are coming through as integers. The funny thing is that when looking at the database using SQLite Manager or SQLite Pro the results there are displayed correctly. As a temporary fix...
by: klia | last post by:
hey folks i am facing this problem in my following codes where i am trying to create a database using pysqlite and load data from text file where data is arranged in this form "Birthday2|12/5/2008|HTC|this is my birthday" but i could connect to the database, create it into my current working directory but i can't load the data from my text file in same working directory, i don't know the exact syntax for doing that. Also can someone help to...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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: 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...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
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: 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...

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.