[Zope] Getting a Mysqldb.Connection objetct form ZMySAQLDA

Martin Gebert Murphy@members.netsolution-net.de
Mon, 16 Dec 2002 19:16:18 +0100


Gilles Lenfant schrieb:

>Martin,
>
>Yes, it would be very useful to get a DB API compliant Connection object
>from a Zope DA. There are so many "goodies" for Python I can get from a
>MySQLdb.Connection object that are not available from a ZMySQLDA.
>
OK, what about using an External Method importing MySQLdb then?

>The SQL query is built dynamically in a method of a Python product. I really
>need this to get from the cursor object some data I *cannot* get from ZSQL
>method (like the last autoincrement insert row).
>
select last_insert_id() as ID

works for me.

>It's very shorter to write...
>cursor = dbconnect.cursor()
>cursor.execute("update mytable...", (data, data...))
>
??? Short? OK, call me a newbie, but I've come across no update 
statement so far which I couldn't comfortably code in a Z SQL method. 
Maybe you could explain in more detail what magic you're up to?

>Using the method you suggest is overkill. (why make it simple when you can
>have it complicated :-)
>
Hm, I'd see it the other way round (Cursor coding in Python more 
complicated than using Z SQL/DA), but if you think so...

>Okay, I'm gonna parse the ZMySQLDA connection string to get my own DB API
>Connection object.
>  
>
You can get the Connection String from the connection_string attribute 
of your ZMySQL instance.

>Cheers
>
>--Gilles
>
>PS : please CC your replies to zope@zope.org
>
Sorry, I forgot. I'm pampered from the german DZUG list which sets a 
"Reply to" automatically on every mailing... *big hint for the list 
admins* ;-)

Martin