I'm trouble with a simple python+mysql+reportalab script called by LV. The problem is that the 1st time i run the vi there is no proble, but the 2nd,3rd,.. time doesnt work with a error PYTHON Execute Script__ogtk.vi->python_report.vi:<type 'exceptions.TypeError'>,
The LabVIEW vi does the following steps:
0) create a new python session
1) read the script from file
2) set the 3 string variables select_obj, table, where
3) runs the script
4) close the python session
the python script is the following
import MySQLdbfrom reportlab.pdfgen import canvasdb=MySQLdb.connect(host="localhost",user="root", passwd="password",db="test")
cursor = db.cursor()
cursor.execute("SELECT %s FROM %s WHERE %s" % (select_obj, table, where) )
c = canvas.Canvas("prova.pdf")
y=700;
while 1:
row = cursor.fetchone()
if row == None: break
c.drawString(100, y, "Description: %s || Allarm? %s" % row)
y = y - 100
c.drawString(100, y, "Number of rows returned: %d" % cursor.rowcount)
cursor.close()
db.close()
c.showPage()
c.save()
someone else encountered a similar behaviour?