I need to upadte, add and delete rows from the auth.models.User table, unfortunately…
when I do so the table locks and I cannot perform any SELECT queries against the table.
I’m surrounding these queries by @transaction.commit_manually, which might have something to do with the tables locking.
The transaction look like the following:
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()
Also I’m using Sql Server 2008, I would like to know if it’s Sql Server specific or such actions would lock the table in PostgreSQL and MySQL too.
Any ideas guys? 🙂
Yes, you lock the tables on purpose. I would suggest studying transaction isolation because it is one of the core concepts of databases.
As for your problem, you could do several things, for both the UPDATE and the SELECT statements: