SQL help, please!

I am running the following:

TimeValue = event.source.parent.getComponent(‘CurrentTime’).text
insertQuery = “INSERT INTO linedata (timestamp) VALUES (’%s’)”
system.db.runUpdateQuery(insertQuery %(TimeValue),“DemoSQL”)

The code is supposed to take the current time (string), and write it into a new row in a database (linedata) in a column (timestamp).
The code runs, but does nothing - nada.
What could be the problem?
Appreciate it!

Try this instesd

TimeValue = event.source.parent.getComponent('CurrentTime').text insertQuery = "INSERT INTO linedata (timestamp) VALUES ('%s')" % TimeValue system.db.runUpdateQuery(insertQuery, "DemoSQL")

I don’t see anything wrong with your code. How do you know nothing is happening? Are you getting any errors? Any errors in the Output Console? Are you getting any new rows in the linedata database table? Are you looking in the right database?

You will need single quotes around ‘timestamp’. Otherwise it will treat timestamp as a python variable. :wink: