I am using psycopg2 2.6.1
. I have a bunch of queries that I need to execute in sequence.
conn = psycopg2.connect(database=redshift_database,
You should explicitely regenerate the cursor in the except bloc in case something went wrong at a lower level that the query:
for query in queries:
try:
cursor.execute(query)
except:
print e.message
try:
cursor.close()
cursor = conn.cursor()
except:
conn.close()
conn = psycopg2.connect(...)
cursor = conn.cursor()