Hello
I went through this forum Arduino Yun: Storing Data in Mysql installed on Linino - Arduino Yún - Arduino Forum
but i am still struggle to get it right, when i run the python script in the IDE it uploads onto mysql,
but when i try running the script on putty in the arduino yun, i get a NameError: name 'con' is not defined error.
here is my code, thanks in advance.
#!/usr/bin/python
-- coding: utf-8 --
import _mysql
import sys, string, os
try:
con = _mysql.connect(host='127.0.0.1', user='root', passwd='12345*', db='students')
con.query("INSERT INTO maindata (Cellphone, vote) VALUES (9999,0)")
except _mysql.Error, e:
print "Error %d: %s" % (e.args[0], e.args[1])
sys.exit(1)
finally:
if con:
con.close()