mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-04 04:14:58 +00:00
changed db connection
This commit is contained in:
@@ -108,15 +108,6 @@ def move():
|
|||||||
db_connection.close()
|
db_connection.close()
|
||||||
return jsonify({"status": "success", "direction": direction})
|
return jsonify({"status": "success", "direction": direction})
|
||||||
|
|
||||||
@app.route("/database")
|
|
||||||
def database():
|
|
||||||
db = get_db()
|
|
||||||
cursor = db.cursor()
|
|
||||||
cursor.execute("SELECT * FROM kobuki_data")
|
|
||||||
rows = cursor.fetchall()
|
|
||||||
cursor.close()
|
|
||||||
return str(rows)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/data', methods=['GET'])
|
@app.route('/data', methods=['GET'])
|
||||||
def data():
|
def data():
|
||||||
@@ -139,7 +130,7 @@ def data():
|
|||||||
|
|
||||||
# Database-insert
|
# Database-insert
|
||||||
db = get_db()
|
db = get_db()
|
||||||
cursor = db.cursor()
|
with db.cursor() as cursor:
|
||||||
|
|
||||||
# Zorg dat je tabel `kobuki_data` kolommen heeft: `name` en `value`
|
# Zorg dat je tabel `kobuki_data` kolommen heeft: `name` en `value`
|
||||||
sql_sensor = "INSERT INTO kobuki_data (name, value) VALUES (%s, %s)"
|
sql_sensor = "INSERT INTO kobuki_data (name, value) VALUES (%s, %s)"
|
||||||
|
Reference in New Issue
Block a user