Next Previous Contents

2. Trouble with ZMySQLDA

There are a few tricks to getting Zope's ZMySQLDA to work with _mysql. But it ain't that hard, really. Also see the ZMySQLDA HOWTO.

2.1 Building ZMySQLDA

The basic steps are:

  1. Install MySQLdb first, so that it's on your PYTHONPATH and Zope can find it.
  2. Untar the ZMySQLDA tarball (available from zope.org).
  3. Patch it with the ZMySQLDA.patch included with the MySQLdb distribution. In the directory that you did the untar,
    patch -p1 </path/to/ZMySQLDA.patch
    

  4. If you do a make, which is what the ZMySQLDA instructions tell you, it will try to compile the older MySQLmodule, which you don't need. Ignore stuff like:
    ./MySQLmodule.c: In function `pythonify_row':
    ./MySQLmodule.c:238: warning: assignment from incompatible pointer type
    ./MySQLmodule.c: In function `pythonify_res_fields':
    ./MySQLmodule.c:384: invalid lvalue in unary `&'
    ./MySQLmodule.c: In function `STH_fetchdict':
    ./MySQLmodule.c:1125: invalid lvalue in unary `&'
    ./MySQLmodule.c:1147: invalid lvalue in unary `&'
    make: *** [MySQLmodule.o] Error 1
    

    MySQLmodule.c doesn't compile against MySQL-3.22 without patches. Which is why MySQLdb exists...
  5. Restart Zope. You should have a ZMySQLDA Product in the Control Panel.

2.2 How do I use it?

I'm not the best person to ask. There are two main steps to getting started.

  1. Create a ZMySQLDA Connection object somewhere.
  2. The connect string syntax is "database@host user password". If the database is on the same host as the Zope server, you can leave out @host. You might be able to leave off user and password as well, depending on your GRANT tables. Whether or not this is a good idea is another question.
  3. You're on your own. I recommend reading the Z SQL Method's User Guide and maybe searching the Zope website for SQL.

Next Previous Contents