title: How to bundle multiple sql codes into one block for python to run?
body: <p>I want to create a table through a python script running sql but want to clear any ones with the same name which may already exist.  The below code produces an error &quot;mysql.connector.errors.ProgrammingError: 1064 (42000): 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 'CREATE TABLE groceries(<code>id</code> int(11) NOT NULL AUTO_INCREMENT,<code>item</code> varchar(25) D' at line 1&quot;.</p>
  <p>I can get the code to work line by line individually but not sure how to combine it all into one script so it runs at the same time through python.</p>
  <pre><code>import mysql.connector
  
  db = mysql.connector.connect(
      host = &quot;localhost&quot;,
      user= &quot;test&quot;,
      password = 'test',
      database = &quot;grocery&quot;
  )
  
  cursor = db.cursor()
  sql = &quot;DROP TABLE IF EXISTS groceries, CREATE TABLE groceries(`id` int(11) NOT NULL AUTO_INCREMENT,`item` varchar(25) DEFAULT NULL, `name` varchar(25) DEFAULT NULL, `quantity` int(11) DEFAULT NULL,PRIMARY KEY (`id`))&quot;
  
  
  
  
  cursor.execute(sql)
  </code></pre>