Dear all,
I am trying to get data from a MySQL database from the Webiopi script.py but I get this error all the time: ImportError: No module named MySQLdb
From my Webiopi webpage, when I click a button, I need to get a value from the database.
My python script starts with this instruction: "import MySQLdb as mdb"
Further down, I have a Webiopi macro with following code:
@webiopi.macro
def getTankLevel():
con = mdb.connect("db_ip_address", "username", "password", "database")
curs=con.cursor()
try:
curs.execute ("""SELECT field1 FROM table ORDER BY id DESC LIMIT 1""")
except:
con.rollback()
for rows in curs.fetchall():
outStr = str(rows[0])
con.close()
return "%s" %(outStr)
Could you help me explaining if this is possible to do and if so, how can I do it?
Thank you in advance.
regards