Thread: Python + PostgreSQL

Python + PostgreSQL

From
Antonio Navarro Navarro
Date:
Hi All !

I have installed postgresql-python-7.0.2-2.i386.rpm in a RedHat 6.2 box.
Where can I find documentation for this module ? I'm trying to connect to a
server but the python says 'no password supplied'

import pg

dg = pg.connect("template1", "localhost", 5432)

Regards,

Antonio Navarro Navarro
BemarNet Management
http://www.bemarnet.es
hostmaster@bemarnet.es
Tlf. +34-96-1656644
Fax. +34-96-1656514


Re: Python + PostgreSQL

From
Karl Thomas Diedrich
Date:
I used the Postgresql python package to write a program. I couldn't find
any documentation either. Examples come in the RedHat package.

I used qit like this:
from pg import DB
cnx = DB("database-name")
cnx.query("""CREATE TABLE ...""")

You can see the full application at http://deodas.sourceforge.net/. Thqe
parts in the the file DEODAS/deodas/src/deodas_mod.py under CVS web. 


Karl Diedrich 
died9501@uidaho.edu
http://www.uidaho.edu/~died9501/
http://deodas.sourceforge.net/

On Wed, 2 Aug 2000, Antonio Navarro Navarro wrote:

> Hi All !
> 
> I have installed postgresql-python-7.0.2-2.i386.rpm in a RedHat 6.2 box.
> Where can I find documentation for this module ? I'm trying to connect to a
> server but the python says 'no password supplied'
> 
> import pg
> 
> dg = pg.connect("template1", "localhost", 5432)
> 
> Regards,
> 
> Antonio Navarro Navarro
> BemarNet Management
> http://www.bemarnet.es
> hostmaster@bemarnet.es
> Tlf. +34-96-1656644
> Fax. +34-96-1656514
> 



Re: Python + PostgreSQL

From
Antonio Navarro Navarro
Date:
At 14.48 2/8/00 -0700, Karl Thomas Diedrich wrote:

>I used the Postgresql python package to write a program. I couldn't find
>any documentation either. Examples come in the RedHat package.
>
>I used qit like this:
>from pg import DB
>cnx = DB("database-name")
>cnx.query("""CREATE TABLE ...""")
>
>You can see the full application at http://deodas.sourceforge.net/. Thqe
>parts in the the file DEODAS/deodas/src/deodas_mod.py under CVS web. 

Hi Karl !

Yes, this works for localhost and for servers that don't need user
authentication, but I need to connect to a remote server using an specific
username and password... Anyone can help ?

Regards,

Antonio Navarro Navarro
BemarNet Management
http://www.bemarnet.es
hostmaster@bemarnet.es
Tlf. +34-96-1656644
Fax. +34-96-1656514


Re: Python + PostgreSQL

From
darcy@druid.net (D'Arcy J.M. Cain)
Date:
Thus spake Karl Thomas Diedrich
> I used the Postgresql python package to write a program. I couldn't find
> any documentation either. Examples come in the RedHat package.

Look at the actual distribution either in the PostgreSQL tree or download
the package from http://www.druid.net/pygresql/ and look at the README file.

> I used qit like this:
> from pg import DB
> cnx = DB("database-name")
> cnx.query("""CREATE TABLE ...""")

The reccommended way is now;

import pg
cnx = pg.DB("database-name")

The reason for this is to make pg.error and possibly other things available.

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.


Re: Python + PostgreSQL

From
darcy@druid.net (D'Arcy J.M. Cain)
Date:
Thus spake Antonio Navarro Navarro
> I have installed postgresql-python-7.0.2-2.i386.rpm in a RedHat 6.2 box.
> Where can I find documentation for this module ? I'm trying to connect to a
> server but the python says 'no password supplied'
> 
> import pg
> 
> dg = pg.connect("template1", "localhost", 5432)

If the server requires a password then you need to supply one here.  If
you don't need a password (i.e. "psql template1" works) then try this.

import pg
dg = pg.DB("template1")

Note DB is preferred over connect but the main change is not to use localhost
to connect.  The default is to use a Unix socket rather than TCP/IP to
localhost and PostgreSQL treats that differently.  If localhost was just
used here for illustrative purposes and in fact you are connecting over
TCP/IP to another machine then look at pg_hba.conf to adjust permissions
or add a password to the connection call.

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.


Re: Python + PostgreSQL

From
Antonio Navarro Navarro
Date:
At 10.05 3/8/00 -0400, darcy@druid.net (D'Arcy J.M. Cain) wrote:

>Thus spake Antonio Navarro Navarro
>> I have installed postgresql-python-7.0.2-2.i386.rpm in a RedHat 6.2 box.
>> Where can I find documentation for this module ? I'm trying to connect to a
>> server but the python says 'no password supplied'
>> 
>> import pg
>> 
>> dg = pg.connect("template1", "localhost", 5432)
>
>If the server requires a password then you need to supply one here.  If
>you don't need a password (i.e. "psql template1" works) then try this.

Hi again !

How must I add the password to the call , maybe
dg = pg.connect("template1", "10.0.0.1", 5432,"username", "password") ?

and where could I find documentation for the different functions supplied
in the package ?

Regards,

Antonio Navarro Navarro
BemarNet Management
http://www.bemarnet.es
hostmaster@bemarnet.es
Tlf. +34-96-1656644
Fax. +34-96-1656514


Re: Python + PostgreSQL

From
"David Lloyd-Jones"
Date:
The full text of the O'Reilly book Learning Python is online at
http://www.ibooks.com/ free of charge -- as a promotion for giving them your
e-mail address. They are a new venture hoping to sell "e-books" over the
Net, so this is a promotion to get their list started, and Learning Python
isone of the four books they make available as a freebie.
                                                              -dlj.


----- Original Message -----
From: "Antonio Navarro Navarro" <hostmaster@bemarnet.es>



Re: Python + PostgreSQL

From
darcy@druid.net (D'Arcy J.M. Cain)
Date:
Thus spake Antonio Navarro Navarro
> >If the server requires a password then you need to supply one here.  If
> >you don't need a password (i.e. "psql template1" works) then try this.
> 
> Hi again !
> 
> How must I add the password to the call , maybe
> 
>  dg = pg.connect("template1", "10.0.0.1", 5432,"username", "password") ?
  connect(dbname, host, port, opt, tty, user, passwd)

Set any unused parameters to None.

> and where could I find documentation for the different functions supplied
> in the package ?

In the README that comes with the distribution.

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.


Re: Python + PostgreSQL

From
Bob Kline
Date:
On Fri, 4 Aug 2000, David Lloyd-Jones wrote:

> The full text of the O'Reilly book Learning Python is online at
> http://www.ibooks.com/ free of charge -- as a promotion for giving
> them your e-mail address. They are a new venture hoping to sell
> "e-books" over the Net, so this is a promotion to get their list
> started, and Learning Python isone of the four books they make
> available as a freebie.

Interesting.  Unfortunately, their home page doesn't say anything about
this.  Have a more direct URL?

-- 
Bob Kline
mailto:bkline@rksystems.com
http://www.rksystems.com



Re: Python + PostgreSQL

From
"David Lloyd-Jones"
Date:
From: "Bob Kline" <bkline@rksystems.com> asks:


> On Fri, 4 Aug 2000, David Lloyd-Jones wrote:
>
> > The full text of the O'Reilly book Learning Python is online at
> > http://www.ibooks.com/ free of charge -- as a promotion for giving
> > them your e-mail address. They are a new venture hoping to sell
> > "e-books" over the Net, so this is a promotion to get their list
> > started, and Learning Python isone of the four books they make
> > available as a freebie.
>
> Interesting.  Unfortunately, their home page doesn't say anything about
> this.  Have a more direct URL?
>

Hi Bob,

Here's my URL for it:

http://www.ibooks.com/SiteSrvr/SSS007X9JCVYKRB0NK5CNL765KAWJ1MKEU3FG/bmrsrc/
WPgs/SiteBrowser.htm?Op=7&BIN=1&frames=1

Problem is, that addresses a cookie on my disk after I've registered for it.

You might give the first part of that, http://www.ibooks.com/SiteSrvr/, a
try and see what happens. Alternately, look for the penguin on the right
hand side of the page, and look at the fine print in its vicinity.
                                            Cheers,
                                                    -dlj.






Re: Python + PostgreSQL

From
Bob Kline
Date:
On Fri, 4 Aug 2000, David Lloyd-Jones wrote:

> You might give the first part of that,
> http://www.ibooks.com/SiteSrvr/, a try and see what happens.
> Alternately, look for the penguin on the right hand side of the
> page, and look at the fine print in its vicinity.

Tried your suggestions, and have come to the conclusion that they
decided to withdraw the offer.

-- 
Bob Kline
mailto:bkline@rksystems.com
http://www.rksystems.com