I am working on a project in which I am using python to store sensor data in a SQLite Database.
If the table does not exists it will be created like this:
query_db('create table if not exists %s (id INTEGER PRIMARY KEY AUTOINCREMENT, value double, datetimestamp DATETIME, user CHAR(2));' % (sensor_name+'_VALUES'))
Next I want to insert the values from a HTTP Post Request:
sensor_value = request.json['value']
dtstamp = request.json['timestamp']
user_name = request.json['user']
result = query_db('INSERT INTO %s ("value", "datetimestamp", "user") VALUES ( "%s" ,"%s" , "%s");' % (sensor_name + '_VALUES', sensor_value, dtstamp, user_name))
But I don't get an error and it also seems like the insert is not executed. The request looks like this:
{
"value" : 22,
"timestamp" : "2017-02-17 22:22:22",
"user" : "TE"
}
Anyone know why?