467,915 Members | 1,780 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,915 developers. It's quick & easy.

Which Python module for PostgreSQL?

Hi,

I'm not new to Python, but new to databases and PostgreSQL.
I like to write a PostgreSQL client application (not code
running inside of the RDBMS), and Debian has four modules:

python2.3-pgsql - A Python DB-API 2.0 interface to PostgreSQL v7.x
python2.3-popy - module providing access to PostgreSQL from Python2.3
python2.3-psycopg - Python 2.3 module for PostgreSQL
python2.3-pygresql - PostgreSQL module for Python

Now I'm confused: Which one should I use? I'm going to try
python2.3-psycopg, but maybe the other variants are "easier
to use"? Or faster? Or more complete? Thread-safe?

Thanks in advance for your hints!

Cheers,
--
W. Borgert <de*****@debian.org>

Jul 18 '05 #1
  • viewed: 2206
Share:
9 Replies
>>>>> "W" == W Borgert <de*****@debian.org> writes:
Hi,
I'm not new to Python, but new to databases and PostgreSQL.
I like to write a PostgreSQL client application (not code
running inside of the RDBMS), and Debian has four modules: python2.3-pgsql - A Python DB-API 2.0 interface to PostgreSQL v7.x
python2.3-popy - module providing access to PostgreSQL from Python2.3
python2.3-psycopg - Python 2.3 module for PostgreSQL
python2.3-pygresql - PostgreSQL module for Python


I prefer the first one - it's BSD licensed, actively maintained and
supported. It's also very compatible with the python SQLite binding which I
use regularly.

Ganesan

--
Ganesan R

Jul 18 '05 #2
I'd like to know too - I had a play with psychog but couldn't get it
to connect, and couldn't find any documentation for it.

I don't have a huge amount of PostgreSQL knowledge (more of a MySQL
person myself) so I could have it setup wrong, but I couldn't figure
anything out as the error message was useless (something about IDENT
user).
Jul 18 '05 #3
W. Borgert:
python2.3-pgsql - A Python DB-API 2.0 interface to PostgreSQL v7.x
python2.3-popy - module providing access to PostgreSQL from Python2.3
python2.3-psycopg - Python 2.3 module for PostgreSQL
python2.3-pygresql - PostgreSQL module for Python

Now I'm confused: Which one should I use?


I scanned the newsgroups and documentation with the same question some
time ago. I can't remember all the reasons, but I chose pgsql. No regrets.

--
René Pijlman
Jul 18 '05 #4
simo wrote:
I'd like to know too - I had a play with psychog but couldn't get it
to connect, and couldn't find any documentation for it.

I don't have a huge amount of PostgreSQL knowledge (more of a MySQL
person myself) so I could have it setup wrong, but I couldn't figure
anything out as the error message was useless (something about IDENT
user).


It's a PostgreSQL question, really. It sounds like the user account you're trying
to connect to the database from doesn't have the necessary permissions. I can
hardly imagine that a copy-and-paste strategy of the exact error message into
Google wouldn't have led you further ;-)

-- Gerhard

Jul 18 '05 #5

simo> I'd like to know too - I had a play with psychog but couldn't get
simo> it to connect, and couldn't find any documentation for it.

If you're familiar with SQL programming in Python in general, it's pretty
straightforward. It does adhere to v2 of the DB API, so PEP-249 is useful
reading. Also, see the doc/examples directory. Here's a psycopg "hello
world" (change the connect arg to suit your server):

import psycopg
conn = psycopg.connect('dbname=test user=test')
curs = conn.cursor()
curs.execute("""select 'hello world'""")
print curs.fetchall()

Skip

Jul 18 '05 #6
In article <ou************@andlx-anamika.cisco.com>, Ganesan R wrote:
python2.3-pgsql - A Python DB-API 2.0 interface to PostgreSQL v7.x
python2.3-popy - module providing access to PostgreSQL from Python2.3
python2.3-psycopg - Python 2.3 module for PostgreSQL
python2.3-pygresql - PostgreSQL module for Python


I prefer the first one - it's BSD licensed, actively maintained and
supported. It's also very compatible with the python SQLite binding which I
use regularly.


PyGreSQL (the first one), doesn't seem to handle boolean's correctly in
Python 2.3. Is there a workaround (aside from translating back and forth
before saving)? This is the version that ships with Red Hat 9.

I use psycopg usually, though I try to test my progs with all of them
(except popy). It's not too hard to accomadate all of them with just a few
tweaks (usually in the way they handle booleans), since they all use
pyformat.

pyPgSQL does seem to have the best win32 support.

Dave Cook
Jul 18 '05 #7
>>>>> "David" == David M Cook <da******@nowhere.net> writes:
In article <ou************@andlx-anamika.cisco.com>, Ganesan R wrote:
python2.3-pgsql - A Python DB-API 2.0 interface to PostgreSQL v7.x
python2.3-popy - module providing access to PostgreSQL from Python2.3
python2.3-psycopg - Python 2.3 module for PostgreSQL
python2.3-pygresql - PostgreSQL module for Python
I prefer the first one - it's BSD licensed, actively maintained and
supported. It's also very compatible with the python SQLite binding which I
use regularly.


I was referring to python2.3-pgsql which is the same as pyPgSQL.
PyGreSQL (the first one), doesn't seem to handle boolean's correctly in
Python 2.3. Is there a workaround (aside from translating back and forth
before saving)? This is the version that ships with Red Hat 9.


I presume you meant to say "the last one" :-).

Ganesan

--
Ganesan R

Jul 18 '05 #8
In article <ou************@andlx-anamika.cisco.com>, Ganesan R wrote:
I was referring to python2.3-pgsql which is the same as pyPgSQL.


Oh, those wacky Debian kids and their renamings. I assumed pgsql was the
"standard" module that ships with postgres.

pyPgSQL seems to handle booleans quite transparently.

Dave Cook
Jul 18 '05 #9
>

I use psycopg usually, though I try to test my progs with all of them
(except popy). It's not too hard to accomadate all of them with just a few
tweaks (usually in the way they handle booleans), since they all use
pyformat.

Hmm, this is why I use C-style booleans (e.g. an integer where 0 means
false and not 0 means true).
It is totally portable (can be used with any DBMS and with any DB-API
module). I can be wrong doing
this but it works fine for me.

G

Jul 18 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Patrick Useldinger | last post: by
reply views Thread by chuck amadi | last post: by
18 posts views Thread by David Rysdam | last post: by
10 posts views Thread by Andrew Dalke | last post: by
13 posts views Thread by Aquarius | last post: by
reply views Thread by Adam Smith | last post: by
48 posts views Thread by northband | last post: by
reply views Thread by krishnakant Mane | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.