Re: [pysqlite] [ANN] pysqlite 2.5.2

"Edzard Pasma" <[email protected]> Thu, 5 Mar 2009 01:10:24 -0800
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
--- [email protected] wrote:

>> class Connection (sqlite.Connection):
>>     def cursor (self):
>>         return Cursor (self)

> Here's the problem. do this instead:

> return sqlite.Connection.cursor(self)

OK, but does it still use my custom CUrsor class then?

> Basically, constructing Connection and Cursor objects directly instead
> of via dbapi2.connect or Connection.cursor was no intended use, thus not
> tested, thus buggy ;-)

This is rather confusing. I'd propose to not expose the Cursor as a class at all if it is not intended to be used as such. One can still adapt it:

class Mycursor:
  def __init__ (self, con):
      self._cursor = con.cursor ()
  def execute (self, *args):
      print "EXEC", args
      self._cursor.execute (*args)   
  ...