title: Postgresql write csv to table loop failing unexpectedly mid-loop
body: <p>I'm trying to iterate through a series of CSV files (all of which have identical table structure), with a for loop reading each CSV file in, writing it to a postgresql table (same structure as CSV files), and iterating on to the next CSV file.</p>
  
  <p>I've got about 600 CSVs I want to iterate through, and my for loop works flawlessly for the first 33 iterations, but for some reason every single iteration after that fails.</p>
  
  <p>At first I thought it was an issue with the constraints I'd placed on the fields within my postgrgesql table (i.e. NOT NULL/UNIQUE constraints). However when I attempt to write any of the files manually via Postico they commit without any issue (which also weeds out any data type mis-matches as a potential cause I think?).</p>
  
  <pre class="lang-py prettyprint-override"><code>import psycopg2
  from lister import list_generator
  
  conn = psycopg2.connect("host=localhost dbname=backend user=macbookpro")
  cur = conn.cursor()
  
  list = list_generator('testing.csv')
  
  n = 0
  
  for a in list:
      try:
          with open('Testing/'+ str(a) +'.csv', 'rb') as f:
              next(f)
              cur.copy_from(f, 'table1', sep=',')
              conn.commit()
              print(str(n) + " " + str(a) + " completed")
              n += 1
      except:
          print(str(n) + " " + str(a) + " failed")
          n += 1
          pass
  </code></pre>