views:

1851

answers:

4

I've seen a number of postgresql modules for python like pygresql, pypgsql, psyco. Most of them are Python DB API 2.0 compliant, some are not being actively developed anymore. Which module do you recommend? Why?

+6  A: 

psycopg2 seems to be the most popular. I've never had any trouble with it. There's actually a pure Python interface for PostgreSQL too, called bpgsql. I wouldn't recommend it over psycopg2, but it's recently become capable enough to support Django and is useful if you can't compile C modules.

Jim
Another pure-Python option: pg8000 ( http://pybrary.net/pg8000/ )
Adam Bernier
+1  A: 

Psycopg1 is known for better performance in heavilyy threaded environments (like web applications) than Psycopg2, although not maintained. Both are well written and rock solid, I'd choose one of these two depending on use case.

zgoda
Psycopg 1 is terribly out of date: its use is absolutely not advisable.
piro
+1  A: 

I suggest Psycopg over Psycopg2 since the first one seems a bit more sable. At least in my experience. I have an application running 24/7 and sometimes I was getting random memory crashes (double free or corruption errors) from Psycopg2. Nothing I could have debug fast or easily since it's not a Python error but a C error. I just switched over to Pyscopg and I did not get any crashes after that.

Also, as said in an other post, bpgsql seems a very good alternative. It's stable and easy to use since you don't need to compile it. The only bad side is that library is not threadsafe.

Pygresql seems nice, there's a more direct way to query the database with this library. But I don't know how stable this one is though.

550
As stated in another comment, there is plenty of bugs in Psycopg 1 that have been fixed in Psycopg 2 in about 4 years of development. Please report any bug to the mailing list.
piro
+1  A: 

I uses only psycopg2 and had no problems with that.

Simon