> I've read examples from Zope 2 where they used a DTML
> page that called a ZSQL method such as the following:
> <dtml-in river_info>
> <dtml-var river_id>
> <dtml-var river_name>
> ZSQL method would then contain:
> SELECT river_id, river_name FROM river_info
> In Zope 3, I only see an option to add a SQL script
> which I'm pretty sure is not the same thing as a ZSQL
It is the same thing, at last in the way it works.
> method since I've copied the above into a SQL script
> and "Test"ing the script by itself does in fact read
> from the MySQL database, but I can not access the SQL
> script from a DTML page. I get the following error:
> A server error occurred."
Take look at site error log or at log/transcript.log
to see full traceback.
Simplest thing you should do is to
1. Create database
connection object. For MySQL you should use:
Create this object TTW, enter proper connection string and
check if it works with Test tab. Then click at Registration
tab and register connection object under specific name.
2. Create SQLScript object
At the add form you should see Connection field and you should be
able to chose connection you've created at point 1 (that is why
your connection had to be registered).
3. Enter SQL statements into SQLScript object, save and test it
4. create view to display data from SQLScript
Read about relational database connectivity in Zope2 book.
A lot of thing is valid with zope3 too.
> So, some very basic questions :
> What is the suggested way to access a MySQL database
> from Zope 3.
In fact you may use traditional way (as above) or use
ORMs like SQLObject or SQLAlchemy. Not sure what is
preffered. For me this is up to personal preferences.
Zope3-users mailing list