Hi,
 
In Ubuntu 9.10, we had sqlite3 3.6.16. In that version, we were able to
execute a select from within commit hook.
But in version 3.7.7, we see that the select causes call of commit hook,
and this caused infinite recursion.
We were able to workaround this, but just wanted to mention in case it
is a bug and not intentional.
Below is the python code that works with 3.6.16, but not with 3.7.7. 
 
 
#!/usr/bin/env python
import apsw, sqlite3, re, os, sys
import pdb
 
class Hook:
  def __init__(self):
    self.apsw_conn=apsw.Connection("./test.db")
    self.conn=sqlite3.connect(self.apsw_conn)
    self.cursor=self.conn.cursor()
    self.apsw_conn.setcommithook(self.make_commithook())
 
    sqlstmt = "INSERT INTO  TestTable1 VALUES ('A', 1);"
 
    if apsw.complete(sqlstmt):
        try:
            stmt = self.cursor.execute(sqlstmt)
            self.conn.commit()
        except sqlite3.Error, e:
            self.conn.rollback()
            print str(e)
    else :
        print 'Incomplete SQL statement'
 
  def make_commithook(self):
      """Closure for commithook method to be registed as a callback """
      def f ():
          self.commithook()
      return f
 
  def commithook(self):
      print "commithook called"
      stmt = "SELECT * FROM TestTable2;"
      rows = self.cursor.execute(stmt).fetchall()
      print rows
 
 
if __name__ == "__main__":
  hook = Hook()
 
 
Thank you for providing sqlite3. It is useful and reliable.
 
Thanks,
Raman
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to