oh, whoops, shouldnt be a lambda there:
def setup(**kwargs):
def connect():
return MySQLdb.connections.Connection(**kwargs)
engine = create_engine('mysql://', creator=connect,
pool_recycle=2)
On Dec 19, 2008, at 6:56 PM, Ken wrote:
>
> Oh, I see. I was unaware that lambda evaluated the result only once,
> not each use. Thanks so much for your help.
>
> On Dec 19, 4:36 pm, Michael Bayer <[email protected]> wrote:
>> def setup(**kwargs):
>> connection = MySQLdb.connections.Connection(**kwargs)
>> engine = create_engine('mysql://', creator=lambda: connection,
>> pool_recycle=2)
>>
>> the "creator" argument is a callable that returns a new connection
>> when the pool needs one. Above, you are pre-connecting a single
>> MySQL
>> connection and returning it from the lambda. Besides producing non-
>> mutexed multithreaded access to the single Connection itself (which
>> may or may not be OK for MySQLdb), it also prevents a new connection
>> from being created once it has been recycled. The previous
>> connection, now closed, is all that's available.
>>
>> The correct form is:
>>
>> def setup(**kwargs):
>> def connect():
>> return MySQLdb.connections.Connection(**kwargs)
>> engine = create_engine('mysql://', creator=lambda: connect,
>> pool_recycle=2)
>>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---