forget it. it's weird that read lock for mysql is read only, i have to obtain write lock. it seems not possible to block write access only.
On Wednesday, October 17, 2012 2:55:49 AM UTC+8, vince wrote: > > i tried to lock table but with error > <class 'gluon.contrib.pymysql.err.InternalError'> (1099, u"Table > 'publication' was locked with a READ lock and can't be updated") > > db.executesql('LOCK TABLE publication READ;') > result = db(db.publication.id==pubid).select()[0] > newlist = result.photo_list > newlist.remove(int(pid)) > db(db.publication.id==pubid).update(photo_list=newlist) > db.executesql('UNLOCK TABLES;') > > is it possible to use the same connection? > > On Thursday, October 11, 2012 9:32:14 PM UTC+8, Massimo Di Pierro wrote: >> >> You can try: >> >> db.executesql('LOCK TABLE tablename READ;') >> >> >> http://aarklondatabasetrivia.blogspot.com/2009/04/how-to-lock-and-unlock-tables-in-mysql.html >> >> >> On Thursday, 11 October 2012 01:44:14 UTC-5, vince wrote: >>> >>> can i lock a table as readonly during the transaction? the case is i >>> need to insert a record to table B which is base on the query result of >>> table A, i would like to lock table A as readonly until i finish the insert. >>> >>> i am using mysql at the moment. i know web2py may not have this feature, >>> what is the best way to use mysql's 'lock table' on web2py? >>> >>> thanks in advance, >>> vince >>> >> --