title: How to debug 'You have an error in your SQL syntax'
body: <p>There are several questions on <code>You have an error in your SQL syntax</code> - but they all seem to address a specific syntax error in the query, which is generally not helpful to others.</p>
  
  <p>My question is how can I get the formatted query from a MySQL command in Python so that I can actually inspect it?</p>
  
  <p>So I have a statement like:</p>
  
  <pre><code>cursor.execute("INSERT INTO products(acc, title, sku, price, price_checked, desc, imgs) VALUES (%s,%s,%s,%s,%s,%s,%s)", (1, prod.title, prod.sku, prod.price, datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), prod.desc, prod.imgs))
  </code></pre>
  
  <p>And the error 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 n
    ear 'desc, imgs) VALUES (1,'Holy Stone HS700 FPV Drone with 1080p HD Camera Live Vide' at line 1")</p>
  </blockquote>
  
  <p>Any idea how I can get the executed query? I don't want to format the query myself then print it before executing, but rather use MySQL's built in formatting for security reasons, mainly.</p>