feat: add save_sensor_data function to insert sensor data into the database

This commit is contained in:
ishak jmilou.ishak
2025-01-09 13:54:15 +01:00
parent 015b2db819
commit 9a3829cdb2

View File

@@ -90,5 +90,14 @@ def database():
cursor.close()
return str(rows)
def save_sensor_data(data):
db = get_db()
cursor = db.cursor()
sql = "INSERT INTO kobuki_data (data) VALUES (%s)"
value = data
cursor.execute(sql, (value,))
db.commit()
cursor.close()
if __name__ == '__main__':
app.run(debug=True, port=5000)