1 Nov 2004 01:17
Re: MySQLdb DictCursor class
Il giorno ven, 29-10-2004 alle 22:25 -0400, Ed Leafe ha scritto: > > def getDictCursorClass(self): > > import MySQLdb.cursors as cursors > > return cursors.DictCursor > > To make the question even simpler: when you do the following in > psycopg: > > import psycopg > dsn = ... > conn = psycopg.connect(dsn) > crs = conn.cursor() > > What is the class of 'crs' in the above? More specifically, how would > it be referenced if a subclass were to be defined that used that class? in psycopg 1.1 cursors and connections can't be subclassed. in psycopg 2 you can subclass both and pass a 'factory' argument to the right function to have the engine instantiate objects of your type instead of the standard type. the types 'connection' and 'cursor' are in psycopg.extensions and the methods involved are: psycopg.connect(dsn, ..., factory=connection_class) conn.cursor(factory=cursor_class) hope this helps, federico
RSS Feed