Re: autocommit property broken with MySQL

Jacob Smullyan <[email protected]> Wed, 17 Aug 2005 11:30:58 -0400
Newsgroups gmane.comp.web.skunkweb
Message-ID <[email protected]>
On Tue, Aug 16, 2005 at 11:22:54AM -0700, Matthew Bogosian wrote:
> Attached is a patch (made from SVN #1628) to implement the proposal 
> alluded to above. This patch gets rid of the autocommit property 
> altogether and provides a new parameter to DB aliases called 'initSQL' 
> which can be a string or a sequence of strings. If present, the 
> statement(s) will be executed (in sequence) immediately after 
> connection creation.

Thanks for the concept and the patch!

I checked something in just now to support this kind of thing, but I
didn't use your patch as is, because I don't think it works correctly
with pools.  The initialization shouldn't take place every time the
dbi object connects -- when using a pool it would then initialize the
same connection twice.  I do the initialization in _real_connect
instead. 

Also, rather than using initSQL, I accept a parameter, "init", to
initAlias, which can be a string or a callable.  If it is a callable,
it should accept one argument, the new connection.  If it is a string,
it is turned into a callable that executes the string as sql on the
connection.  (I forgot for a moment that you accepted a list of
strings, which is a good idea, and I'll go back and add that.)

There are some changes to the api, but really only those to the
internal PyDO-developer api are backwards-incompatible; the initAlias
change doesn't break old code.

I've only verified that the regression tests still work; I don't know
if the initialization works yet.  Let me know if you try it.  Also, I
still have been putting off fixing autocommit, for some peculiar and
no doubt pathological psycological non-reason.

js
-- 
Jacob Smullyan
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDA1gyuqamFyFXXLIRAhXAAKC/rMkdH1uTmX0L8yyCpqn0Jvgx3wCeIDvF
MnyS+VCCX6fyjneArjdfPBg=
=OToy
-----END PGP SIGNATURE-----