title: What is the advantage of using multiple cursors in psycopg2 for PostgreSQL queries?
body: <p>What is the difference between using a single cursor in psycopg2 to perform all your queries against using multiple cursors. </p>
  
  <p>I.e, say I do this:</p>
  
  <pre><code>import psycopg2 as pg2
  con = psycopg2.connect(...)
  cur = con.cursor()
  cur.execute(...)
  ....
  ....
  cur.execute(...)
  ...
  </code></pre>
  
  <p>and every time I wish to execute a query thereafter, I use the same cursor <code>cur</code>.</p>
  
  <p>Alternatively I could do this every time I want to query my database:</p>
  
  <pre><code>with cur as con.cursor():
      cur.execute(...)
  </code></pre>
  
  <p>In which case, my cursor <code>cur</code> would be deleted after every use. </p>
  
  <p>Which method is better? Does one have an advantage over another? Is one faster than the other? More generally, why are multiple cursors for one connection even needed?</p>