Serial communication with mysql

Please i need help. am trying to publish sensor data read from serial port to mysql databse in real time.

below are my code. Rasberry can connect to mysql but the data are not displayed. can anyone help please

#!/usr/bin/env python
import MySQLdb
import serial

#Setup database
db = MySQLdb.connect(host="localhost", user="root",passwd="pass", db="Sensordb")
cur=db.cursor()

while True:
#Poll sensor and record data
datetime = (time.strftime("%Y-%m-%d ") + time.strftime("%H:%M:%S"))

if name == 'main':
while True:
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=1)
ser.flush()
if ser.in_waiting > 0:
line = ser.readline().decode('utf-8').rstrip()

sql = ("INSERT INTO temperature (id, Time, Celcius, Fahrenheit) VALUES (%s,%s,%s,%s)",(line, line, line, line))

try:

Insert and commit data to database

cur.execute(*sql)
db.commit()
print "Data committed"

except:

Rollback in case there is any error

db.rollback()
print "Failed writing to database"

cur.close()
db.close()
break
ser.close() # Only executes once the loop exits

You'd get some good help on the Raspberry Pi site in the Python topic