Dear All,
I have a problem while data logging in the single DB table in SQL server. We are not able to do it. When we are running the python code in raspberry pi we are getting the following error msg.
ERROR MESSAGE
Py Code:
I have a problem while data logging in the single DB table in SQL server. We are not able to do it. When we are running the python code in raspberry pi we are getting the following error msg.
ERROR MESSAGE
Error:File "./insertDB.py", line 19
//cursor = con.cursor(prepared=True)
^
SyntaxError: invalid syntax
Please anyone help me out. Py Code:
import serial import time import MySQLdb as mdb arduino = serial.Serial("/dev/ttyACM0") arduino.baudrate=9600 data = arduino.readline() time.sleep(1) data = arduino.readline() pieces = data.split("\t") temperature = pieces[0] humidity = pieces[1] #This is a comment con = mdb.connect('localhost', 'root', '12345678', 'testdb'); with con: //cursor = con.cursor(prepared=True) sql_insert_query = """ INSERT INTO TempDB (temperature, humidity) VALUES (%s,%s)""" insert_tuple = (temperature, humidity) cursor.execute(sql_insert_query, insert_tuple) con.commit()