On 19/01/2010 01:24, Christoph Zwerschke wrote: > Bob Kline wrote: >> Are the deficiencies in each of the drivers so serious that so many >> programmers are driven to roll their own? Or are these the >> outgrowths of ambitious student projects? > > This has historical reasons. Python and PostgreSQL are both around for a > long time and have evolved quite a bit, and there were two DBAPI > releases. These developments prompted people to create new drivers using > the new standards, but some of the older projects were not given up and > modernized as well. PyGreSQL started even before DBAPI, but is still > maintained and quite stable; it provides the old interface in addition > to a newer DBAPI 2 module. pyPgSQL has the special feature of returning > rows as dictionary. Psycopg2 is more modern, sophisticated (built-in > connection pooling) and can be considered the mainstream. Then of > course, there are also drivers for platforms different from traditional > CPython, such as JDBC, .NET, pure Python drivers etc.
In fact the main feature of psycopg is not connection pooling (just an extra to show the possibility to subclass connection and cursor objects) but type adaptation that let you specify how to convert any Python type to PostgreSQL and back. If you want a row as a dictionary you just need to subclass cursor and pass the new type to the connection and voilĂ !, your new cursor can override the fetchXXX methods and build dicts instead of tuples (in fact this example is included in the psycopg2.extras module.) federico -- Federico Di Gregorio f...@initd.org Those who do not study Lisp are doomed to reimplement it. Poorly. -- from Karl M. Hegbloom .signature
signature.asc
Description: OpenPGP digital signature
_______________________________________________ DB-SIG maillist - DB-SIG@python.org http://mail.python.org/mailman/listinfo/db-sig