Skip to content

Commit

Permalink
Updates with ssl disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
nmagee committed Nov 18, 2024
1 parent 05cbba1 commit f1bbcb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
16 changes: 7 additions & 9 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/usr/bin/env python3

from fastapi import FastAPI
from typing import Optional
from pydantic import BaseModel
# from typing import Optional
# from pydantic import BaseModel
import mysql.connector
from mysql.connector import Error
import json
import os

DBHOST = "ds2022.cqee4iwdcaph.us-east-1.rds.amazonaws.com"
DBUSER = "ds2022"
DBUSER = "admin"
DBPASS = os.getenv('DBPASS')
DB = "nem2p"

db = mysql.connector.connect(user=DBUSER, host=DBHOST, password=DBPASS, database=DB)
db = mysql.connector.connect(user=DBUSER, host=DBHOST, password=DBPASS, database=DB, ssl_disabled=True)
cur=db.cursor()

app = FastAPI()
Expand All @@ -32,23 +32,23 @@ def zone_apex():

@app.get('/genres')
async def get_genres():
query = "SELECT * FROM genres ORDER BY . genreid;"
db = mysql.connector.connect(user=DBUSER, host=DBHOST, password=DBPASS, database=DB)
query = "SELECT * FROM genres ORDER BY genreid;"
try:
cur.execute(query)
headers=[x[0] for x in cur.description]
results = cur.fetchall()
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')
async def get_genres():
cur = db.cursor()
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 @@ -57,8 +57,6 @@ async 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
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
uvicorn
fastapi[standard]
typing
pydantic
# typing
# pydantic
mysql-connector-python
# pymongo
# dnspython
Expand Down

0 comments on commit f1bbcb7

Please sign in to comment.