python and Postgresq

D

Diez B. Roggisch

Andy said:
Hi,

Does anyone have a link to, or can provide an example script for using
python-pgsql (http://pypi.python.org/pypi/python-pgsql/) or if someone can
recommend an alternative, that would be fantastic.

I'd recommend psycopg2.

This is an introduction:

http://www.devx.com/opensource/Article/29071

But google yields tons more. And make sure you read the python db api 2.0
spec, this should give you the general idea on how to work with Python &
RDBMS, which is nicely abstracted away from the actual database.

http://www.python.org/dev/peps/pep-0249/

Diez
 
A

Andy dixon

Diez B. Roggisch said:
I'd recommend psycopg2.

This is an introduction:

http://www.devx.com/opensource/Article/29071

But google yields tons more. And make sure you read the python db api 2.0
spec, this should give you the general idea on how to work with Python &
RDBMS, which is nicely abstracted away from the actual database.

http://www.python.org/dev/peps/pep-0249/

Diez

Amazing. Works like a charm!

Thanks..

I used the code (stripping out certain bits) if anyone else may find it
useful:

#!/usr/bin/env python
import psycopg

def main():
connection = psycopg.connect('host=<HOST> dbname=<DB> user=<USER>
password=<PASSWORD>')
mark = connection.cursor()
query='SELECT * FROM table'
mark.execute(query)
record = mark.fetchall()
for i in record:
print i
return

if __name__ == '__main__':
main()
 
K

Krishnakant

I'd recommend psycopg2.

This is an introduction:

http://www.devx.com/opensource/Article/29071

But google yields tons more. And make sure you read the python db api 2.0
spec, this should give you the general idea on how to work with Python &
RDBMS, which is nicely abstracted away from the actual database.

Python-pgsql is a much better choice when it comes to big applications,
specially if you are going to deal with xml-rpc. I have found that
python-pgsql handles integers and other such postgresql datatypes
better.

Happy hacking.
Krishnakant.
 
D

Diez B. Roggisch

Krishnakant said:
Python-pgsql is a much better choice when it comes to big applications,
specially if you are going to deal with xml-rpc. I have found that
python-pgsql handles integers and other such postgresql datatypes
better.

Where is the connection between XMLRPC and psql? And can you elaborate on
what and how pgsql handles things better than psycopg2?

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top