From 9a3829cdb2f53038dba1a471de6b1a7d490d4c40 Mon Sep 17 00:00:00 2001 From: "ishak jmilou.ishak" Date: Thu, 9 Jan 2025 13:54:15 +0100 Subject: [PATCH] feat: add save_sensor_data function to insert sensor data into the database --- src/Python/flask/web/app.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Python/flask/web/app.py b/src/Python/flask/web/app.py index a666754..59fe855 100644 --- a/src/Python/flask/web/app.py +++ b/src/Python/flask/web/app.py @@ -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)