1 Apr 2010 08:31
Re: use sqlite3.Row when subclassing connection
Hello, On Wed, Mar 31, 2010 at 4:29 PM, hjebbers <hjebbers@...> wrote: > hi, > > I am trying to use the conn.row_factory = sqlite3.Row functionality, > but have not succeeded so far. > reason might be that subclassed the connection class (in order to use > a subclassed cursor) > > def connect2sqldb(database): > [...] First, please send an exact minimalist example if you send code again. The code in your mail couldn't possibly work at all. "conn terug" "sqlite" vs "sqlite3". The problem is that there's an undocumented part with row_factory. What's really used is Cursor.row_factory, which is undocumented. Cursor.row_factory is copied from Connection.cursor() into the cursor instance. Of course this can only happen if you do not completely override Connection.cursor. Here's example code that works as intentended: import sqlite3 def connect2sqldb(database): con = sqlite3.connect(database, factory=MyConnection) con.row_factory = sqlite3.Row con.execute("PRAGMA synchronous=OFF")(Continue reading)
RSS Feed