Code: Select all
def sendtempvaluesSQL():
#Maak connectie met server van Timo in garage.
my_connection = MySQLdb.connect(host='192.168.0.110' , user='test' , passwd='xxxxx', db='i2craspberrypi')
cursor = my_connection.cursor()
lm96temp = i2c.read_byte_data(i2c_lm96, 0x00)
lm96eindtemp = lm96temp * 1.9
lm96eindtempstring = str(lm96eindtemp)
localtime = time.asctime( time.localtime(time.time()) )
print localtime
sql = "INSERT INTO mainunittempwaarden (Waarde, DatumTijd) VALUES ('%s','%s')" %(lm96eindtemp, localtime)
try:
cursor.execute(sql)
my_connection.commit()
except:
my_connection.rollback()
my_connection.close()
print "sql saved"