PyGreSQL difficulties

Jim Driese jdriese at seanet.com
Fri Oct 8 08:41:01 EDT 1999


Jim Driese 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:
>
> __________________________________________________________________
> MODULE BASICS.PY : BASIC SQL COMMANDS TUTORIAL
>
> This module is designed for being imported from python prompt
>
> In order to run the samples included here, first create a connection
> using :                        cnx = basics.DB(...)
> then start the demo with:      basics.demo(cnx)
> __________________________________________________________________
>
> So, I typed:
>
> 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?
>
> TIA
>
> Jim Driese

Okay, I figured out that "..." is the name of the database.   Here's a
sample session:

>>> cnx.query("create table cities (name text,population float8,altitude
int)");
>>> cnx.query("create table capitals (state varchar(2)) inherits
(cities)");
>>> cnx.query("create unique index on cities using btree (name)");
Traceback (innermost last):
  File "<stdin>", line 1, in ?
pg.error: ERROR:  parser: parse error at or near "on"

So, table creation went ok but I was unable to create an index (I _can_ do
this under psql, however).  None of the sample programs had an index
example.  Does anybody know of a good online pygres reference?

TIA

Jim Driese













More information about the Python-list mailing list