PyGreSQL difficulties

D'Arcy J.M. Cain darcy at vex.net
Fri Oct 8 08:48:11 EDT 1999


Jim Driese <jdriese at seanet.com> wrote:
> I'm new to Python and am trying to get the PyGreSQL module to work.  I
> am running FreeBSD 3.3-STABLE and installed the Python-1.5.2 package and
> PyGreSQL-2.4 port.  When I ran basics.py interactively (import basics),
> I received the following message:

Just so you know, the whole demo area has not received as much attention
as it should so don't be too surprised if there are some rough edges
here and there.

> cnx = basics.DB(...)

> and received the following error message:

> SyntaxError: invalid syntax

> What am I supposed to enter for "..." and what do I need to do to get
> the sample program to run?

You need to replace the elipsis with whatever args you need to connect to
a database.  See the README for details on the connect() call which takes
the same arguments as the DB class.  The init function in DB just calls
connect with the args given.  For example, if you are opening a database
on the local machine with the name matching your login name then you can
just use the following.

cnx = basics.DB()

More commonly you would name the database here.

cnx = basics.DB('mytest')

and finally, here is a more complicated example.

cnx = basics.DB('mytest', 'db.otherdomain.com', user = 'guest', passwd = 'abc')

-- 
D'Arcy J.M. Cain <darcy at caingang.com>      |  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.




More information about the Python-list mailing list