title: Python MySQLDB Insert with variables as parameters
body: <p>I am using Python-MySQLdB library.</p>
  
  <p>I am trying to connect to the MySQL DB from a python script. I have a requirement where when the users register their account automatically the details should be added/saved to the MySQL DB.
   I'm trying to automate this feature using python.</p>
  
  <p>The script is running successfully and the values are not reflected in the DB. What might be the issue ??</p>
  
  <p>This is the script.</p>
  
  <pre><code>import sys
  import MySQLdb as mdb
  import datetime
  username ='trail'
  password='trial'
  companyname="trialuser"
  imei = '0'
  tval = 'T'
  try:
      con = mdb.connect('localhost', 'root', 'test', 'collect');
      cur = con.cursor()
      currdate = d = datetime.date.today() + datetime.timedelta(days=30)  
      cur.execute("""
  INSERT INTO user (companyName,user,pass,imei, checkPoint,licenceDate) VALUES (%s,%s,%s,%s,%s,%s) """,(companyname,username, password,imei,tval,currdate))
      print 'Succesfully Inserted the values to DB !' 
  except mdb.Error, e:
      print "Error %d: %s" % (e.args[0],e.args[1])
      sys.exit(1)   
  finally:    
      if con:    
         con.close()
  </code></pre>