title: Mysqldb INSERT INTO syntax error in Python
body: <p>I have an excel file which I am trying to put into mysql. There are 32 fields which I want to extract using the python plugin xlrd and put into mysql. The data is laid out like so:</p>
  
  <p><img src="https://i.stack.imgur.com/At14K.png" alt="Data Layout"></p>
  
  <p>My methodology is to iterate over the rows and columns, adding fieldnames as I go. The code adds the field name but then there is an error when adding the data. (I created the table 'OilProvedReservesHistory' with an index as the only field):</p>
  
  <p><img src="https://i.stack.imgur.com/tdv20.png" alt="SQL Layout"></p>
  
  <pre><code>def get_data_from_sheet(sheet_index, table, start_row, end_row, end_col):
  
  for row in range(start_row - 1, end_row - 1):
      for col in range(end_col):
          cell = sheet.cell(row,col)
          if col == 0:        
              fieldname = cleanup_field(cell.value)
              if fieldname != ("Blank Cell"):
                  sql = "ALTER TABLE OilProvedReservesHistory ADD %s VARCHAR(20)" % fieldname
                  c.execute(sql)                  
          else:
              data = cleanup_data(cell)
              if data != ("Blank Cell"):
                  postToMySQL(data,fieldname,table)
  
  
  def postToMySQL(data,fieldname,table):
  #Generate sql query string                
  sql = "INSERT INTO " + table + " ("+ fieldname + ") VALUES %s"
  c.execute(sql, data)
  # Executes: ("""INSERT INTO OilProvedReservesHistory (US) VALUES 36.533""")
  
  table = create_table_from_sheet_name()
  
  sheet_index = 0
  start_row = 5
  end_row = 68
  end_col = 32
  
  get_data_from_sheet(sheet_index, table, start_row, end_row, end_col)
  </code></pre>
  
  <p>The error I get is:</p>
  
  <blockquote>
    <p>_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to  use near ''36.533'' at line 1")</p>
  </blockquote>
  
  <p>Can you help me get this working? Thanks a lot!</p>