title: reuse of cursor in django
body: <p>In shell interface of django <code>(python manage.py shell)</code>, I am able to resuse <code>cursor</code> object multiple times to query something, which I generate from <code>connection</code> with command </p>
  
  <pre><code>from django.db import connection 
  cursor = connection.cursor()
  </code></pre>
  
  <p>However, when I define a cursor in a module globally and try to use it multiple times in a function, it failes after one usage. It is being closed, so I need to create it again at the beginning of the function. Why it is not working in module while it works on shell interface?</p>
  
  <p><strong>Note:</strong> It is not directly related with django. Django uses <code>Python Database API</code> stated <a href="http://legacy.python.org/dev/peps/pep-0249/#cursor" rel="nofollow">here</a>. However, I still do not know whether it is problem due performance issue, recreating cursors from connections before every query operation.</p>