title: Python MySQL Connector - cursor won't commit()
body: <p>I have python (3.4) code and the cursor just won't commit it to the database. I can commit the changes if I type them in manually through the MySQL client (so I'm sure that I have <code>UPDATE</code> permissions on the relevant table). This code just updates a table with info from a csv file:</p>
  
  <pre><code>#!/bin/python3.4
  import mysql.connector
  import csv
  import sys
  
  cnx = mysql.connector.connect(user='me', password=sys.argv[1] , host="localhost", database="mydb")
  cursor = cnx.cursor()
  csvfile = open("products.csv", 'r', newline='')
  products = csv.DictReader(csvfile, delimiter = ',', quotechar='"', skipinitialspace=True)
  
  update_product= ("UPDATE products SET "
      "ticket_price = %(ticket_price)s, "
      "quantity_ordered = %(quantity_ordered)s "
      "WHERE product_code = \"%(product_code)s\";"
  )
  for row in products:
      data = {
          "product_code":row["product_code"],
          "ticket_price":row["ticket_price"],
          "quantity_ordered":row["quantity_ordered"]
      }
      cursor.execute(update_product, data)
      print(row["product_code"] + " quantity_ordered: " + row["quantity_ordered"])
  # Commit to the database
  cnx.commit()
  cursor.close()
  csvfile.close()
  cnx.close()
  </code></pre>
  
  <p>As it's a prepared statement, I don't believe I can retrieve the actual SQL string executed (but calling <code>print(update_product % data)</code> lets me look at how the statement is supposed to appear). From manually copy-pasting into the python interpreter, I believe the SQL is OK (<code>cursor.fetchwarnings()</code> doesn't complain). The input data is good; the print statement reads correctly. It just won't commit - all the info in the database remains zero for those rows. I've compared this script to an almost identical one that works, and nothing seems different. I've also tried <code>cnx.autocommit = True</code>, which doesn't work either.</p>
  
  <p>Anyone know how what's wrong, or how to get the <code>cursor.execute()</code> and <code>connector.commit()</code> return statuses so I can debug? <a href="http://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlconnection-commit.html" rel="nofollow">The API</a> doesn't seem to mention, and testing leads me to believe that these methods don't actually return a value. I feel a little blind because of this - I'm supposed to call a method, and pray something happens?</p>
  
  <p><strong>Edit:</strong>
  Out of frustration, I've just generated an SQL file using <code>print(update_product % data)</code>. The database accepts it just fine. I can also update the <code>products</code> table with static values via python, but not dynamic ones.</p>