Postgresql - Preferred Python Library
matt at pollenation.net
Fri Sep 10 10:20:38 CEST 2004
On Fri, 2004-09-10 at 06:28 +0000, Harald Massa wrote:
> > I have noticed that there are a numbe rof client libraries for
> > connecting to Postgres.
> > Can anyone tell me what is the recommended Python library for database
> > connections
I've just started experimenting with psycopg2
(http://wiki.initd.org/Projects/PsycopgTwo) and it's looking good.
As far as I know, psycopg2 is the only DB-API 2.0 implementation for
PostgreSQL that uses Python 2.3's datetime types by default. In fact, I
think it supports *all* native Python types that have a corresponding
database type. For me, this makes a big difference. I find moving data
from RDBMS to application to RDBMS quite irritating and it just makes
matters worse when I have to convert between data types too.
Assuming I don't come across any serious issues, I will be using
psycopg2 from now on.
(I also use dateutil, <https://moin.conectiva.com.br/DateUtil>, which
extends datetime with lots of useful stuff. So useful, it should
probably be part of the standard library.)
> I recommend pyPgSQL - http://pypgsql.sourceforge.net/
> it gives you high level (DBAPI2) and if you wish also low level access
> Twisted seems to use it, to.
Twisted's adbapi will use any DB-API 2.0 implementation with a
threadsafety level of 1 or greater. I have tested one application with
pypgsql, pygresql, psycopg and psycopg2. Twisted was happy with all of
them, although differences in how python and column types are handled
means the application code is not necessarily portable by default.
See <http://twistedmatrix.com/documents/current/howto/enterprise> for
more information on using an RDMBS from a Twisted application.
/ \__ Matt Goodall, Pollenation Internet Ltd
\__/ \ w: http://www.pollenation.net
__/ \__/ e: matt at pollenation.net
/ \__/ \ t: +44 (0)113 2252500
/ \ Any views expressed are my own and do not necessarily
\__/ reflect the views of my employer.
More information about the Python-list