[Zope-DB] dynamic SQL

Fernando Martins fmartins@hetnet.nl
Wed, 9 Apr 2003 00:36:23 +0200


Hi,

I'm creating a form which can be used to build queries by the user. It's not
a general purpose query designer, but it involves a few tables and I'll have
to create several quite different queries.

I don't want to go through the trouble of manually preparing all the
possible queries (ZSQL methods) in antecipation. I would like the form to
call a PythonScript which will build the SQL statement and then _somehow_
run it and _somehow_ return a second web page, a ZPT page which can use the
results sequence to show it to the user.

So, two questions:

- how can I execute the SQL statement to get a sequence?

- how can I send the second page built with the results from the
PythonScript to the user?
(I believe I can use 'options' in zpt to receive parameters from a Script,
but I'm not sure this is the best option for this case).

Another possibility would be to pass the SQL statement to the second ZPT
page and run it there _somehow_. Hmm, using 'options' I could pass the SQL
statement and in the ZPT page I can call a python script which executes the
SQL statement and returns a sequence. But how can I have a Script executing
a SQL statement?

TIA,
Fernando