[sqlalchemy] Re: How to lock tables in mysql with SqlAlchemy?
jason kirtland 写道: Ting Zhou wrote: Dear All, I would like to lock a table like LOCK TABLES table_name in mysql command. How can I do that with SqlAlchemy. I have defined a class |//|//|class Pointer(Entity): using_options(tablename='Pointer',autosetup=True) id=Field(MSInteger,primary_key=True) ||I need to lock table ||'Pointer'.|// You can lock the tables by executing the SQL directly. I'm not sure what that looks like in Elixir, but in plain SA it'd be something like: conn = engine.connect() conn.execute(LOCK TABLES Pointer WRITE) ... do stuff with conn conn.execute(UNLOCK TABLES) Thank you. This is what I am doing at the moment. I am hoping it can be done more pythonically. Best wishes Ting --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: How to lock tables in mysql with SqlAlchemy?
On Apr 25, 2008, at 2:50 AM, Ting Zhou wrote: Thank you. This is what I am doing at the moment. I am hoping it can be done more pythonically. locking tables is a coarse grained action that can lead to deadlocks. Finer grained row locking is available using SELECT...FOR UPDATE which the ORM supports directly using query.with_lockmode(read|update), and select() supports using the for_update keyword argument: select([cols], for_update=True|read) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: How to lock tables in mysql with SqlAlchemy?
Ting Zhou wrote: Dear All, I would like to lock a table like LOCK TABLES table_name in mysql command. How can I do that with SqlAlchemy. I have defined a class |//|//|class Pointer(Entity): using_options(tablename='Pointer',autosetup=True) id=Field(MSInteger,primary_key=True) ||I need to lock table ||'Pointer'.|// You can lock the tables by executing the SQL directly. I'm not sure what that looks like in Elixir, but in plain SA it'd be something like: conn = engine.connect() conn.execute(LOCK TABLES Pointer WRITE) ... do stuff with conn conn.execute(UNLOCK TABLES) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---