From df6a49bbaaa18a098ef00624bf6c12e8943d4206 Mon Sep 17 00:00:00 2001 From: "ishak jmilou.ishak" Date: Tue, 17 Dec 2024 13:42:14 +0100 Subject: [PATCH] test to get db info --- src/Python/flask/web/app.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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}")