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

Andreas Jung lists at andreas-jung.com
Thu Feb 17 14:22:00 EST 2005



--On Donnerstag, 17. Februar 2005 13:17 Uhr -0600 "Tuttle, Gene" 
<cetuttle at rottlundhomes.com> wrote:

> 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.  Can any one point me in the right direction?

Why are you using *this* approach. The recommended way is to setup a
DA inside the ZMI and use ZSQL methods for performing SQL operations
through the DA.  Please read the Zope Book RDBMS chapter carefully to get
an idea how to it it the zope-ish way.

-aj



More information about the Zope mailing list