php - Can't insert in a table or create a table in MySQL using Python -


I have an arduino uno and temp36 I read the sensor value with the Python arduino serial monitor. It works !!

But I can not use Python in a built-in MySQL table and I do not know why I do not have any errors or warnings.

  Import serial import time import MySQLdb dbhost = 'localhost' dbname = 'test' dbuser = 'x' dbpass = 'y' ser = serial Serial ('COM7', 9600, timeout = 1) # On the Ubuntu system, / dev / ttyACM0 is the default path to the serial device on Arduinos, you are probably different. While 1: time.sleep (1) the_goods = ser.readline () str_parts = the_goods.split ('') conn = MySQLdb.connect (host = dbhost, user = dbuser, passwd = dbpass, db = dbname) cursor = conn . Include cursor () sql = "arduino_temp (temperature) values ​​('% s');" % (Str_parts [0]) Print "Number of rows entered:% d"% Cursor. Try Orcount: Excluding cursor. Execute (SQL): cursor pass.close () conn.autocommit = true conn.close () printed Do_Good   

Am I doing something wrong?

Hardware: Windows 7, Python 2.7, Python Editor: PieScriptor, Ardino Uno, MySQL WorkBank

P>

You must do this after executing the sql statement:

  cursor          

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

c# - Call function from DLL -