What is the difference between using a single cursor in psycopg2 to perform all your queries against using multiple cursors.
I.e, say I do this:
import psycopg2 as pg2
con = psycopg2.connect(...)
cur = con.cursor()
cur.execute(...)
....
....
cur.execute(...)
...
and every time I wish to execute a query thereafter, I use the same cursor cur.
Alternatively I could do this every time I want to query my database:
with cur as con.cursor():
cur.execute(...)
In which case, my cursor cur would be deleted after every use.
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?