[Zope] using database connection inside of python scripts or how to do a d-hoc queries

Dieter Maurer dieter at handshake.de
Fri Feb 18 14:42:23 EST 2005

Tuttle, Gene wrote at 2005-2-17 13:17 -0600:
>I have been searching for this answer and not finding it.
>Inside a python script I want to create insert queries based on the fields
>returned from a form.
>I tried creating a database connection object like :
>dbcon = context.Psycopg_database_connection()
>Then executing a query like:
>RS = dbcon.query('select * from customer').dictionaries() 
>this does not work.

What happens? You should always tell us the precise problem!

You probably get an "Unauthorized" exception, because
"query" is an internal method.

If you do not (because you execute in trusted code),
then you get an "AttributeError" exception because
"query" returns a tuple and a tuple does not
have a "dictionaries" method.

When you use internal methods, you should carefully
look at their source to learn about arguments and
return values.


More information about the Zope mailing list