title: mysql.connector.errors.ProgrammingError: 1064 (4200): You have an error in your SQL syntax;
body: <p>I am attempting to insert data into a MySQL database. I am using python 2.7 and I am using  the mysql.connector. </p>
  
  <p>My error is: </p>
  
  <blockquote>
    <p>mysql.connector.errors.ProgrammingError: 1064 (4200): 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 '%s) at line 1. </p>
  </blockquote>
  
  <p>This indicates a error in my code where I attempt to insert my variable np (VALUES (%s)");). np is a "noun-phrase" such as a "skate board". </p>
  
  <pre><code>import mysql.connector
  from textblob import TextBlob
  
  cnx = mysql.connector.connect(user='XXX', password='XXX',
                                host='XXXXX',
                                database='XXXX')
  
  cursor = cnx.cursor(buffered=True)
  
  Latest = ("SELECT * FROM SentAnalysis")
  cursor.execute(Latest)
  
  for row in cursor.fetchall():
      SentText = row[2]
      blob = TextBlob(SentText)
      for np in blob.noun_phrases:
          print(np)
          SQLInsertCmd = ("INSERT INTO TestNounPhrase (NPhrase) VALUES (%s)")
          cursor.execute(SQLInsertCmd,np)
  
  cnx.commit()
  cursor.close()
  cnx.close()
  </code></pre>
  
  <p>The example from the manual is <a href="https://dev.mysql.com/doc/connector-python/en/connector-python-example-cursor-transaction.html" rel="noreferrer">https://dev.mysql.com/doc/connector-python/en/connector-python-example-cursor-transaction.html</a>. e.g.</p>
  
  <pre><code> "VALUES (%s, %s, %s, %s, %s)")
  </code></pre>
  
  <p>I can't see a difference. This error is also discussed in detail here : <a href="https://stackoverflow.com/questions/23515347/how-can-i-fix-mysql-error-1064">How can I fix MySQL error #1064?</a> Other similar examples on stackoverflow have been linked to <a href="https://stackoverflow.com/questions/22226488/python-mysqldb-programming-error-1064-when-inserting-data">reserved words</a>, <a href="https://stackoverflow.com/questions/27702026/programmingerror-1064">Redundant comas</a> .But looking at these examples I can't spot an obvious error. </p>
  
  <p>Any suggestions on where I am going wrong would be much appreciated.</p>