Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

python and Postgresq

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


ajd at malcol

Nov 23, 2009, 2:03 AM

Post #1 of 7 (272 views)
Permalink
python and Postgresq

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.

Thanks!

Andy Dixon

--
http://mail.python.org/mailman/listinfo/python-list


deets at nospam

Nov 23, 2009, 2:22 AM

Post #2 of 7 (249 views)
Permalink
Re: python and Postgresq [In reply to]

Andy dixon wrote:

> 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
--
http://mail.python.org/mailman/listinfo/python-list


ajd at malcol

Nov 23, 2009, 2:36 AM

Post #3 of 7 (249 views)
Permalink
Re: python and Postgresq [In reply to]

"Diez B. Roggisch" <deets [at] nospam> wrote in message
news:7mv62nF3hp171U1 [at] mid
> Andy dixon wrote:
>
>> 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

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()


--
http://mail.python.org/mailman/listinfo/python-list


ben+python at benfinney

Nov 23, 2009, 3:01 AM

Post #4 of 7 (249 views)
Permalink
Re: python and Postgresq [In reply to]

"Andy dixon" <ajd [at] malcol> writes:

> 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.

"Diez B. Roggisch" <deets [at] nospam> 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
--
http://mail.python.org/mailman/listinfo/python-list


hackingkk at gmail

Nov 23, 2009, 3:20 AM

Post #5 of 7 (249 views)
Permalink
Re: python and Postgresq [In reply to]

On Mon, 2009-11-23 at 11:22 +0100, Diez B. Roggisch wrote:
> Andy dixon wrote:
>
> > 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.

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.


--
http://mail.python.org/mailman/listinfo/python-list


deets at nospam

Nov 23, 2009, 3:37 AM

Post #6 of 7 (250 views)
Permalink
Re: python and Postgresq [In reply to]

Krishnakant wrote:

> On Mon, 2009-11-23 at 11:22 +0100, Diez B. Roggisch wrote:
>> Andy dixon wrote:
>>
>> > 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.
>
> 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
--
http://mail.python.org/mailman/listinfo/python-list


timr at probo

Nov 24, 2009, 11:19 PM

Post #7 of 7 (227 views)
Permalink
Re: python and Postgresq [In reply to]

Krishnakant <hackingkk [at] gmail> wrote:
>
>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.

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, timr [at] probo
Providenza & Boekelheide, Inc.
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.