[Zope] Non-query SQL with Zope (naive question)
Martijn Pieters
mj@antraciet.nl
Tue, 24 Aug 1999 09:57:36 +0200
At 06:15 24/08/99 , Bruce Elrick wrote:
>Hi all...
>
>I'm just discovering Zope, have installed v1.10.3 on Linux, am using Zserver
>for the http server, and am using PostGreSQL with ZPyGreSQLDA.
>
>I was happily developing my web site, including creating queries of a
>PostGres DB, when I found that I could not create insert, update, or
>deletion SQL commands.
>
>The docs support this fact, but I can't believe that people have not
>wanted to do more SQL beyond just querying. I'm guessing that I could write
>some Python extensions to do that sort of thing, but I'm not a Python
>programmer and I have to believe that someone else wants to do this and is
>working on it already. I imagine the features of the SQLMethods included
>with Zope would be as useful in non-query SQL as they are in querying.
>
>I haven't delved into v2 and the ZClasses that are available there. Looking
>at the contributed Products for v1 on the Zope site, I could not see anything
>that addressed this.
>Update: I found sqlinputwix1.0.tar.gz, which from the name I can only hope is
>what I want, but it is MySQL only. I haven't tried setting up a MySQL DB just
>to see what functionality is provided by this Product.
>
>How do people make full-fledged web applications with DB back ends using Zope?
>Or do they even try?
What problems have you run into when you tried?
ZSQL methods support all SQL your database supports, including updates,
inserts and deletes. When I install a Zope server elsewhere, that uses a
database, I include the table create statements as well. Just run one DTML
method, and the whole database is set up.
The MySQL SQL Input Wizard just creates a few DTML Methods for you, to use
as an example when developing your own inserts and updates. It uses some
non-standardized features of the ZMySQLDA to query table and column
definitions. You don't need it to enable database manipulation.
When you create a ZSQL method, first use it's Test tab to see if your SQL
works. Then you can start calling the method from your DTML. Remember to
put any parameters you want to pass into the SQL Method in the 'Arguments'
field.
Now, if you have a method called 'insertNewContact' with arguments
'name:required' and 'email' and the following SQL:
insert into contacts values
(<!--#sqlvar name type=string-->, <!--#sqlvar email type=string
optional-->)
you can call this from DTML with:
<!--#call "insertNewContact(name='Martijn Pieters',
email='mj@antraciet.nl')"-->
or you can put the parameters in the REQUEST object:
<!--#call "REQUEST.set('name', 'Martijn Pieters')"-->
<!--#call "REQUEST.set('email', 'mj@antraciet.nl')"-->
<!--#call insertNewContact-->
This works the same for updates and deletes, or any other SQL.
--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-7502100 Fax: +31-35-7502111
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------