[ZODB-Dev] Re: Gadfly with ZEO clients - anyone trying this?
Ken Wasetis
kwasetis at sprinc.com
Thu Feb 26 10:34:49 EST 2004
That's exactly what I ended up doing. Ironically enough, one of the few
things Microsoft did well (abstracting the database access layer through
ODBC so that you can connect to any db very easily, though not as
efficiently, of course) was harder to implement with Zope/Python due to
the fact that the ZODBCDA relies on Python 2.1 - and all more recent
versions of Zope use a more recent version of Python (I'm using Python
2.3.2 with Zope 2.7.)
Anyhow, as I said, thankfully I was able to use a native driver, because
someone was kind enough to put one up on sf.net for mysqldb-python. I
had originally avoided the native route, because a month or so ago when
I looked into that path, there was no download which included the C
binaries for Windows, thus necessitating the MS Visual Studio C compiler
- just not worth my troubles/money. But yesterday I was please to find
an .exe installer that included the C binaries within.
This all did not happen without some issue and some effort on my part.
For those other poor saps out there who might be trying to connect MySQL
to Zope on Windows, I found the following two threads very helpful:
http://mail.zope.org/pipermail/zope-db/2003-January/001313.html
http://www.zope-forum.org/forum/viewthread.php?FID=2&TID=4384
The first link alludes to the fact that the mysqldb-python installer on
Windows checks the registry for Python installations - there is no
config file or commandline argument to tell the installer to use the
zope/lib/python. Instead, I had to download the same version of Python
that my Zope uses from python.org so that it's installer would put an
entry in the Windows registry and so the mysqldb-python installer would
then find something to use. The other important item to note from that
link is that once the mysqldb installer is done, you'll need to manually
move the 7 files and 1 folder mentioned into the zope/lib/python (or
whatever python home you're using for Zope.)
Even if you get the mysqldb-python installer to work/compile the Python
source, and you then copy the ZMySQLDA product to your
zope/lib/python/Products folder (and you restart Zope and you see this
as an installed product in the ZMI), when you attempt to add a MySQLDA
connection to your application/site, it will (depending on your version
of various things) still fail, with a 'server_capabilities'
AttributeError. The second link provides a harsh, yet effective hack
for getting around this (setting self.transactions = 1 within the db.py
file of ZMySQLDA.)
After all this mess, I'm able to connect to MySQL, create tables, run
queries, etc. All is well now.
The big test for me was confirming that my MySQL connection object could
be shared from various ZEO clients. This works like a charm. I created
the connection from the ZMI of one ZEO client instance and tested it
from others. No problemo.
Thanks for your suggestions, everyone.
-Ken Wasetis
Chris Withers wrote:
> Ken Wasetis wrote:
>
>> Anyone have any recommendations one way or the other of using
>> Zope/ODBC with MySQL or Postgres or Firebird?
>
>
> Why not just use one of their excellent native adapters and avoid ODBC
> completely?
>
> cheers,
>
> Chris
>
More information about the ZODB-Dev
mailing list