Skip to content

Commit

Permalink
Trying to close my cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
nmagee committed Nov 16, 2024
1 parent fea41de commit 05cbba1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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))
Expand Down

0 comments on commit 05cbba1

Please sign in to comment.