[Zope] Using a SQL database connection in Python scripts

Andreas Tille tillea@rki.de
Tue, 24 Sep 2002 14:18:30 +0200 (CEST)


Hello,

I just created a database connection and want to do some queries from
a Python script and solving the problem without defining explicite
ZSQL methods and just do some queries from the python script.

In a former mail to this list I've got the following hint according to
a similiar question:

Mon, 13 May 2002, Gilles Lenfant <gilles@objectis.net> wrote:

> Zope DAs have a "manage_test" method. The docstring says :
>
> results = someDA.manage_test(query, REQUEST=None)
>
> Executes the SQL in parameter query and returns results
>
> Note you must set the proxy to "manager" to a python script or DTML
> that executes this method.

Thus I tried

   results = context.myDBconnection.manage_test('SELECT * FROM table;', \
                                                REQUEST=None)
   print results
   return printed

And got

   <Shared.DC.ZRDB.Results.Results instance at 0x91327bc>

Hmmm, it seems to work in any way - but how to parse the results
object?

I tired to find some solutions in the Zope Book but failed because it
describes only DTML methods to query databases.  Is there any reason to
use only DTML with databases and my intention has real drawbacks or
is it just a lack of documentation?

Kind regards

         Andreas.