Home | History | Annotate | Download | only in sqlite3
      1 import sqlite3
      2 
      3 class CountCursorsConnection(sqlite3.Connection):
      4     def __init__(self, *args, **kwargs):
      5         sqlite3.Connection.__init__(self, *args, **kwargs)
      6         self.numcursors = 0
      7 
      8     def cursor(self, *args, **kwargs):
      9         self.numcursors += 1
     10         return sqlite3.Connection.cursor(self, *args, **kwargs)
     11 
     12 con = sqlite3.connect(":memory:", factory=CountCursorsConnection)
     13 cur1 = con.cursor()
     14 cur2 = con.cursor()
     15 print con.numcursors
     16