diff --git a/src/Python/flask/web/app.py b/src/Python/flask/web/app.py index 0266bf5..7c85020 100644 --- a/src/Python/flask/web/app.py +++ b/src/Python/flask/web/app.py @@ -64,11 +64,9 @@ def phpmyadmin_passthrough(path): @app.route("/database") def database(): try: - cur = cnx.cursor() - cur.execute("SELECT * FROM kobuki_data") - rows = cur.fetchall() # Haal alle rijen op uit het resultaat - cur.close() - + with cnx.cursor() as cur: + cur.execute("SELECT * FROM kobuki_data") + rows = cur.fetchall() # Haal alle rijen op uit het resultaat return str(rows) except Exception as e: print(f"Database error: {e}")