title: Force Django to commit
body: <p><strong>Setup:</strong></p>
  
  <ul>
  <li>Python script <strong>A</strong> inserts data to a database every 15 minutes</li>
  <li>Python script <strong>B</strong> queries a few of the latest entries from the database every few minutes</li>
  </ul>
  
  <p>Both use Django's ORM, run on the same machine and use a local MySQL database.</p>
  
  <p><strong>The Problem:</strong> <br/>
  <strong>B</strong> fetches entries, except for the latest one, even though <strong>A</strong> saves it <em>minutes</em> before.</p>
  
  <p>I suspected that <strong>A</strong> doesn't close the transaction, thus <strong>B</strong> sees the database without the last entry. Indeed when examining the MySQL logs, I noticed the <code>commit</code> for each <code>INSERT</code> happens right before the <em>next</em> <code>INSERT</code>.</p>
  
  <p>Even though it's supposed to be redundant, I added <code>@commit_on_success</code> decorator to the <strong>A</strong> function that includes the <code>save()</code>, but it did not help.</p>
  
  <p>How can I force Django (or MySQL?!) to commit right after the <code>save()</code>?</p>
  
  <p><strong>UPDATE:</strong> <br/>
  I discovered that the commits <em>DO</em> happen - I was mislead to believe they don't because <a href="https://stackoverflow.com/questions/7025847/mysql-general-query-log-entry-order">MySQL's General Query Log only has 1 sec resolution</a>. <br/>
  In light of this and other new information, I've reasked the question <a href="https://stackoverflow.com/questions/7028091/django-orm-queries-fail-to-select-new-objects">here</a>.</p>