[Zope] ZMySQLDA and LAST_INSERT_ID() under heavy load
Andy Dustman
farcepest at gmail.com
Thu Sep 2 13:45:45 EDT 2004
On Thu, 2 Sep 2004 18:48:27 +0200, Ragnar Beer <rbeer1 at uni-goettingen.de> wrote:
> LAST_INSERT_ID() in MySQL returns the number of the last automatically
> generated autoincrement value on a per-connection basis. Now, as far as I
> understand, when using ZMySQLDA all queries share one connection which
> saves a lot of time, because it is not necessary to open a new connection
> for each and every statement.
No, the DA mechanisms create one connection per thread, so
LAST_INSERT_ID() should be safe. I do recommend incorporating this
into the same Z SQL Method as your INSERT. Note that you must separate
SQL statements in a Z SQL Method with <dtml-var sql_delimiter>.
http://www.zope.org/Documentation/Guides/ZSQL-HTML/ZSQL.1.4.4.html
In other words:
INSERT .... into blah
<dtml-var sql_delimiter>
SELECT LAST_INSERT_ID()
sql_delimiter is actually a null character (\0) as I recall used by
the DA to split up statements.
--
Computer interfaces should never be made of meat.
More information about the Zope
mailing list