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.
Thanks!
Andy Dixon
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
"Diez B. Roggisch" <de...@nospam.web.de> writes:
> I'd recommend psycopg2.
I'd recommend installing ‘psycopg2’, but using it at a slight distance
by installing ‘SQLAlchemy’ <URL:http://sqlalchemy.org/> to give a useful
Pythonic access layer while having full access to SQL whenever needed.
--
\ “People come up to me and say, ‘Emo, do people really come up |
`\ to you?’” —Emo Philips |
_o__) |
Ben Finney
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()
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.
Where is the connection between XMLRPC and psql? And can you elaborate on
what and how pgsql handles things better than psycopg2?
Diez
I wonder if you would mind expanding on the experiences that lead you to
say this. I've use both extensively (plus the old "pg"), and I've found
psycopg to be unconditionally the better choice, especially for big
applications where performance is critical.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.