From 05cbba19acfdc8605d4bc8cd4b63976cae8d89df Mon Sep 17 00:00:00 2001 From: Neal Magee Date: Fri, 15 Nov 2024 21:33:26 -0500 Subject: [PATCH] Trying to close my cursor --- app/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 7b72bad..2f45aea 100755 --- a/app/main.py +++ b/app/main.py @@ -31,7 +31,7 @@ def zone_apex(): return {"Good Day": "Sunshine!"} @app.get('/genres') -def get_genres(): +async def get_genres(): query = "SELECT * FROM genres ORDER BY . genreid;" try: cur.execute(query) @@ -40,13 +40,15 @@ def get_genres(): json_data=[] for result in results: json_data.append(dict(zip(headers,result))) + cur.close() + db.close() return(json_data) except Error as e: print("MySQL Error: ", str(e)) return {"Error": "MySQL Error: " + str(e)} @app.get('/songs') -def get_genres(): +async def get_genres(): query = "SELECT songs.title, songs.album, songs.artist, songs.year, songs.file, songs.image, genres.genre FROM songs JOIN genres WHERE songs.genre = genres.genreid;" try: cur.execute(query) @@ -55,6 +57,8 @@ def get_genres(): json_data=[] for result in results: json_data.append(dict(zip(headers,result))) + cur.close() + db.close() return(json_data) except Error as e: print("MySQL Error: ", str(e))