Django 事务锁定表
我需要更新、添加和删除用户表(auth.models.User)中的行,但不幸的是……
当我这样做的时候,表就被锁住了,我无法对这个表执行任何查询。
我在这些查询周围使用了 @transaction.commit_manually
,这可能和表被锁有关。
这个事务看起来像这样:
for row in csv_reader:
update_sql = "UPDATE auth_user SET last_name = '%s' WHERE username = '%s'" %(row[2], row[0] )
cursor.execute(update_sql)
if not index % 100: print index:
print index
transaction.commit()
另外,我使用的是 Sql Server 2008,我想知道这是否是Sql Server特有的问题,还是在PostgreSQL和MySQL中也会出现这样的表锁情况。
大家有什么想法吗? :)