On Mon, Nov 7, 2011 at 12:41 PM, Raman Muthukrishnan <ra...@xambala.com>wrote:
> 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. > See the 3rd paragraph of http://www.sqlite.org/c3ref/commit_hook.html I admit that we could state this more clearly. Nevertheless, we do state that it is illegal to run sqlite3_step() from within a commit hook. And there is no way to run a SELECT without calling sqlite3_step(). This has always been so. If it worked for you before, then you were just lucky. > 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 > -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users