title: mysql/python connector using a params and a dictionary dying when handling a null value
body: <pre><code>insert_statement = ("INSERT INTO mydb.sets_ledger "
      "( exercise, weight, reps, rpe) "
      "VALUES ( %(Exercise)s, %(weight)s, %(reps)s, %(rpe)s")
  
  #import the CSV file
  workout_file = "squat_rpe.csv"
  file_hook = open(workout_file, 'rb')
  dictionary=csv.DictReader(file_hook)
  
  print dictionary.dialect
  print dictionary.fieldnames
  
  for row in dictionary:
      print row['Day'], row['Exercise'], row['weight'], row['reps'], row['rpe']
      print "==&gt; "
      cursor.execute(insert_statement, row)
  </code></pre>
  
  <p>Is crashing when I feed it a row from the dictionary where one of the columns (in this case 'rpe' column is empty.)</p>
  
  <pre><code>row =    {'rpe': '', 'weight': '60', 'reps': '3', 'Day': '04/26/14', 'Exercise': 'Competition Back Squat’}
  </code></pre>
  
  <p>gives me final error </p>
  
  <pre><code>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 '' at line 1
  </code></pre>
  
  <p>The mysql schema for rpe, reps, weight are all decimal(10,5)</p>
  
  <p>How to use the dictionary/params method of generating the sql queries when you have empty values sprinkled around the data?</p>
  
  <p>===================================</p>
  
  <p>I built a separate test:</p>
  
  <pre><code>import csv
  import mysql.connector
  
  #engage the MySql Table
  cnx= mysql.connector.connect(user='root', host='127.0.0.1', database='mydb')
  cursor = cnx.cursor()
  
  
  insert_statement_dic = ("INSERT INTO mydb.sets_ledger "
      "( exercise, rpe) "
      "VALUES ( %(exercise)s, %(rpe)s)")
  
  insert_statement_tuple = ("INSERT INTO mydb.sets_ledger "
      "( exercise, rpe) "
      "VALUES ( %s, %s)")
  
  tuple_param_10 = ('tuple insert test 10', 10)
  tuple_param_pure_none = ('tuple insert test None', None)
  tuple_param_quoted_none = ('tuple insert test quoted none', 'None')
  
  cursor.execute(insert_statement_tuple, tuple_param_10);
  cursor.execute(insert_statement_tuple, tuple_param_pure_none);
  #cursor.execute(insert_statement_tuple, tuple_param_quoted_none);
  
  dic_param_10 = {'exercise': 'dic_param_10', 'rpe': 19}
  dic_param_None = {'exercise': 'dic_param_None', 'rpe': None}
  dic_param_quoted = {'exercise': 'dic_param_None', 'rpe': 'None'}
  
  cursor.execute(insert_statement_dic, dic_param_10);
  cursor.execute(insert_statement_dic, dic_param_None);
  #cursor.execute(insert_statement_dic, dic_param_quoted);
  
  
  cnx.commit()
  cursor.close()
  cnx.close()
  </code></pre>
  
  <p>To insert a "no value" (NULL) into a decimal column, I need to insert >None&lt;  not >''&lt; and not >'None'&lt;      </p>
  
  <p>The implication is that when I build the dictionary of parameters from the comma-separated-value, I need to do a cleanup function that converst any empty string ('') into a a _builtin.None instead.  (unless I can figure out some way to make the CSV module automatically convert empty-strings ('') into a None.</p>