[Zope3-Users] Guidance on accessing MySQL db.

Andreas Reuleaux reuleaux at web.de
Sat Mar 31 03:05:40 EDT 2007


Admittedly there has not been much documentation
of connecting Zope 3 to a relational database
like MySQL. - Personally I don't have
much experience either. Some hints anyway:


The preferred way is to use an ORM
* either SQLObject -> then use sqlos http://codespeak.net/z3/sqlos/
* or sqlalchemy -> then you have two choices
  - the older one: http://svn.zope.org/z3c.zalchemy/trunk
    demos: z3c.zalchemy/trunk/src/z3c/zalchemy/demo
  - the younger one: http://svn.zope.org/z3c.sqlalchemy/trunk/
(I would go for z3c.sqlalchemy)


Also have a look at
  http://svn.zope.org/mysqldbda/trunk/
for a connection without an ORM
(not sure in what shape that code is)

Maybe the authors of those packages can give better advice.

-Andreas




On Fri, Mar 30, 2007 at 03:32:16PM -0700, Rich C wrote:
> Hello all,
> 
> I've just started using Zope 3 and am having some
> difficulty finding examples on a good way to access a
> MySQL database.  For the moment, I'd just like to be
> able to read from the database and display it in a web
> page with decent formatting. 
> 
> 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>
> </dtml-in>
> 
> 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
> 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:
> 
> "KeyError
> A server error occurred."
> 
> So, some very basic questions :
> What is the suggested way to access a MySQL database
> from Zope 3.  
> 
> Should I even be creating DTML scripts, my
> understanding was that there are better ways of doing
> things than with DTML in Zope 3.  Basically, I just
> want to be able to customize the displaying of whats
> in the database.
> 
> On this list, there was a posting of someone creating
> a content type to access the database.  Maybe this is
> what I need to be doing.  Seems like a lot of
> overhead, as compared to Zope 2.  
> 
> Here is a link to that thread:
> http://mail.zope.org/pipermail/zope3-users/2006-February/002476.html
> 
> Basically, I'm looking for guidance/suggestions on the
> right way to go about doing this.  Any help would be
> greatly appreciated.
> 
> Thanks,
> Rich
> 
> 
> 
>  
> ____________________________________________________________________________________
> Bored stiff? Loosen up... 
> Download and play hundreds of games for free on Yahoo! Games.
> http://games.yahoo.com/games/front
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
> 
> 
> !DSPAM:460d9c8b229491637432971!


More information about the Zope3-users mailing list