[Zope] Using MySQL from a product

Gilles Lenfant gilles@pilotsystems.net
Tue, 29 Jul 2003 18:06:27 +0200


----- Original Message -----
From: "Carsten Gehling" <carsten@gehling.dk>
To: "Zope@Zope.Org" <zope@zope.org>
Sent: Monday, July 28, 2003 11:37 PM
Subject: [Zope] Using MySQL from a product


> I amd creating a product, that needs to communicate with MySQL
> (inserting/updating records and making select queries).
>
> I've installed MySQLdb and Z MySQLDA and can easily create connections
from
> ZMI.
>
> I don't know however, how to communicate directly with MySQL from my
> product. Should I rely on a connection created in ZMI? Or do I create my
own
> connection - if so: how? And how do I make the queries?
>
> - Carsten
>

If you manage the security programmatically, you should prefer using
directly MySQLdb rather than a ZMySQLDA object.
This gives more flexibility and is easier to use for complex queries from
Python.
Warning, you should get the MySQLdb.Connection objects from a pool of
connections : a MySQLdb.Connection object is not thread safe.

--Gilles