title: Not all arguments converted during string formatting (using "question mark" placeholder in Python cursor.execute)
body: <p>I followed the recommendations made <a href="https://stackoverflow.com/questions/902408/how-to-use-variables-in-sql-statement-in-python">here</a> and <a href="https://stackoverflow.com/questions/18053500/typeerror-not-all-arguments-converted-during-string-formatting-python">here</a> to insert records into a MySQL table, but the "not all arguments converted during string formatting" error persists.</p>
  
  <pre><code>import csv
  import MySQLdb
  
  //snip// # MySQL server login code
  
  MyCSV = open('file.csv')
  csv_data = csv.reader(MyCSV)
  
  records = []
  for row in csv_data:
      if "Request_Date" in row:
          # skip header row (field 1 header = 'Request_Date')
          continue
      else:
          records.append(tuple(row))
  
  cursor.executemany('INSERT INTO SchemaName.TableName VALUES 
  (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', records)
  
  MyDB.commit()
  cursor.close()
  MyDB.close()
  </code></pre>
  
  <p>Each tuple in 'records' contains 15 elements, some of which are blank.</p>
  
  <p>print(records[:2]) generates...</p>
  
  <pre><code>[('MM/DD/YYYY', 'first last', 'a-b/c', 'abcde-f', '', '', 'No', '', '', '', '', '', '', 'category-a', ''), ('MM/DD/YYYY', 'first last', 'e-f/g', 'abcde-f', '', '', 'No', '', '', '', '', '', '', 'category-b', '')]
  </code></pre>
  
  <p>Here is the error that results when the 'cursor.executemany' line is run:</p>
  
  <pre><code>  File "C:\Users\mburnett\AppData\Local\Programs\Python\Python36-32\lib\site-packages\MySQLdb\cursors.py", line 238, in execute
      query = query % args TypeError: not all arguments converted during string formatting
  </code></pre>
  
  <p>During handling of the above exception, another exception occurred:</p>
  
  <p>&lt;&lt;&lt;...>>></p>
  
  <pre><code>  File "C:\Users\mburnett\AppData\Local\Programs\Python\Python36-32\lib\site-packages\MySQLdb\connections.py", line 52, in defaulterrorhandler
      raise errorclass(errorvalue)
  _mysql_exceptions.ProgrammingError: not all arguments converted during string formatting
  </code></pre>
  
  <p>I noticed in Kashyap's answer (second link) that his list of tuples ('purchases') has a comma before the last bracket. My list of tuples does not have this trailing comma. If that last comma is necessary for this to work, what's the best method of getting it there?</p>
  
  <p>Thanks in advance!</p>
  
  <p>running Python 3.6.4/Windows 10</p>