[sqlalchemy] Re: How to lock database row on select?

2006-11-15 Thread Basil Shubin

Basil Shubin пишет:
 Hi friends!
 
 I have use SQLAlchemy 0.3 with MySQLdb 1.2.1 How I can lock row in 
 database table when I select it? So nobody can access it in same time.
 BTW I use tables with InnoDB engine.

Okey, I discover 'lockmode' parameter. And how I can use it (or anything 
else) to get this: if I have select the row, so NOBODY can access to it? 
Moreover there be should an exception raised, so I can catch it and show 
to user message box about that database entry is in use by somebody? Is 
this possible and how do you solve this task? I need it to disallow 
mutiple editing/deleting of same entry by different users in same time.

Thanks!

-- 
Basil Shubin
Freelance Software Developer


--~--~-~--~~~---~--~~
 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 database row on select?

2006-11-15 Thread Basil Shubin

Mike Bernson пишет:
 use the lockmode='update' on a query object.
 
 row_obj = query_obj.select(where, lockmode='update').execute()
 

self.localTowns = Table('local_towns', self.metadata,
 Column('id', Integer, primary_key=True),
 Column('title', Unicode(50)),
 mysql_engine='InnoDB')

self.localTowns.create(checkfirst=True)

item = self.localTowns.select(self.localTowns.c.id==itemId, 
lockmode='update').execute()

and I got this error :-(

   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 1332, 
in select
 return select([self], whereclause, **params)
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 65, 
in select
 return Select(columns, whereclause = whereclause, from_obj = 
from_obj, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'lockmode'

-- 
Basil Shubin
Freelance Software Developer


--~--~-~--~~~---~--~~
 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 database row on select?

2006-11-15 Thread Basil Shubin

Mike Bernson пишет:
 use the lockmode='update' on a query object.
 
 row_obj = query_obj.select(where, lockmode='update').execute()

self.localTowns = Table('local_towns', self.metadata,
 Column('id', Integer, primary_key=True),
 Column('title', Unicode(50)),
mysql_engine='InnoDB')

self.localTowns.create(checkfirst=True)

self.session = create_session()

mapper(dbsql.LocalTown, self.localTowns)


item = 
self.session.query(dbsql.LocalTown).with_lockmode('update').execute().selectone(self.localTowns.c.id==itemId)

I got this:

   File /home/bashu/work/devel/wxExpress/lib/database.py, line 95, in 
GetLocalTown
 item = 
self.session.query(dbsql.LocalTown).with_lockmode('update').execute().selectone(self.localTowns.c.id==itemId)
TypeError: execute() takes at least 2 arguments (1 given)

-- 
Basil Shubin
Freelance Software Developer


--~--~-~--~~~---~--~~
 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
-~--~~~~--~~--~--~---