mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
split the data
This commit is contained in:
@@ -96,8 +96,11 @@ def database():
|
||||
def sensor_data(kobuki_message):
|
||||
db = get_db()
|
||||
cursor = db.cursor()
|
||||
sql_sensor = "INSERT INTO kobuki_data (data) VALUES (%s)"
|
||||
cursor.execute(sql_sensor, (kobuki_message,))
|
||||
sql_sensor = "INSERT INTO kobuki_data (name, value) VALUES (%s)"
|
||||
data_dict = json.loads(kobuki_message)
|
||||
sensor_data_tuples = [(name, float(value))for name, value in data_dict.items()]
|
||||
cursor.executemany(sql_sensor, sensor_data_tuples)
|
||||
|
||||
db.commit()
|
||||
cursor.close()
|
||||
|
||||
|
Reference in New Issue
Block a user