main logo
Subject: [dabo-dev] Fwd: [Psycopg] MySQLdb DictCursor class
Author: Ed Leafe
Posted: 2004/10/31 19:50:30
 
View Entire Thread
New Search


Begin forwarded message:

> 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)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -

Looks like psycopg won't be compatible with Dabo without doing a bunch
of work. Good thing that there are other adapters out there!

___/
/
__/
/
____/
Ed Leafe
http://leafe.com/
http://dabodev.com/


 
©2004 Ed Leafe
<-- Prior Message New Search Next Message -->