title: Trouble in sending arduino sensor data to mysql databse via python script
body: <p>I am using DHT11 humidity sensor, Dallas18B20 temperature sensor,reed switch and  hole effect sensor with arduino. I inserted two sensor data(humidity and temperature) into database successfully.But when I try to insert four sensor data to database it is not inserting any of data to the database.Following is my code.I honestly know what is done by pieces[0],pieces[1] here. I referred a example code and did this.for temperature and humidity sensors I wrote <code>cursor.execute("INSERT INTO weatherdata(DateTime,HUMIDITY,TEMPERATUREc) VALUES (NOW(),%s,%s)",(pieces[0],pieces[1]))</code> and it worked perfectly fine. I checked reed switch and hole effect sensors.They are working fine.Please help me on this.</p>
  
  <pre><code>#!/usr/bin/python
  import serial
  import time
  import MySQLdb
  #establish connection to MYSQL.
  dbConn=MySQLdb.connect("localhost","root","raspberry","weather") or die ("could not connect to database")
  #open a cursor to the database
  device="""/dev/ttyACM0"""
  try:
      print "Trying...",device
      arduino=serial.Serial(device,9600)
  except:
      print"Failed to connect on",device
  while True:
      time.sleep(1)
      try:
          data=arduino.readline() #read data from arduino
          print data
          pieces=data.split("\t") #split data by tab
          try:
              cursor=dbConn.cursor()
              cursor.execute("INSERT INTO weatherdata(DateTime,WINDmph,HUMIDITY,RAINmm,TEMPERATUREc) VALUES (NOW(),%s,%s,%s,%s)",(pieces[0],pieces[1],pieces[2],pieces[3]))
              dbConn.commit()
   #commit the insert
              cursor.close() #close the cursor
          except MYSQLdb.IntegrityError:
              print"failed to insert data"
          finally:
              cursor.close() # close incase it failed
      except:
          print"Processing!"
  </code></pre>