[pysqlite] pysqlite2.dbapi2.OperationalError: cannot commit transaction - SQL statements in progress

F. GEIGER f.geiger at vol.at
Wed May 18 15:41:39 EDT 2005


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[0]
      self.commit()
      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_("select count(*) from %s %s" % (self._name,
self._whereClause))
      r = int(self._dbc.fetchone()[0])
      return r

and

   def __delitem__(self, i):
      '''Enables you to remove rows this way: del movies[58]
      '''
      q = "select %s from %s %s %s limit %s, 1" % (self._nameOfIdCol,
self._name, self._whereClause, self._orderClause, i)
      self._query_(q)
      rid = self._dbc.fetchone()[0]
      q = "delete from %s where %s='%s'" % (self._name, self._nameOfIdCol,
rid)
      self._query_(q)
      return

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
Franz GEIGER


PS.: I use pysqlite 2.0.1 on Python 2.3.4





More information about the Python-list mailing list