views:

22

answers:

2

Hi I have some problems that has been bothering me for a week. I am running Selenium testing scripts on my dev machine, and in my test I would call simple script to delete accounts by their sub domain names:

for a in Account.objects.filter(domain = sub_domain):
    a.delete()

The problem is that the query to find all such accounts are not returning correct results after the first time it is run (I use this query to clean up the database before each test). When I set a break point at this point, I can see the query return 0 records, even though in the database it has one record. I also set up mysql query log to see the actual query Django sent to mysql, and the query looks good, and will return correct result if I copy and paste to mysql command shell.

What am I missing? Why Django model query does not give me the correct result? MySQL is using InnoDB engine in case that makes any difference.

A: 

Transactions. Do a COMMIT in the shell.

Ignacio Vazquez-Abrams
Do you mean commit in mysql shell? I tried and it doesn't solve the problem.
ycseattle
Problem solved after changing the MySQL transaction level to read committed. Thanks for the tip!
ycseattle
A: 

This is a recurring problem, so I'm doing a shameless plug with a question in which I described details of the problem:

http://stackoverflow.com/questions/2235318/how-do-i-deal-with-this-race-condition-in-django/2235624#2235624

Tomasz Zielinski