source: trunk/essentials/dev-lang/python/Doc/lib/sqlite3/countcursors.py

Last change on this file was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 455 bytes
Line 
1import sqlite3
2
3class 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
12con = sqlite3.connect(":memory:", factory=CountCursorsConnection)
13cur1 = con.cursor()
14cur2 = con.cursor()
15print con.numcursors
Note: See TracBrowser for help on using the repository browser.