Skip to content

Commit 2ddb975

Browse files
committed
func changes
1 parent ad3c2ac commit 2ddb975

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
CORS(app,supports_credentials=True)
1717

1818

19-
app.config['SQLALCHEMY_DATABASE_URI'] = SupabaseInterface.get_postgres_uri()
19+
app.config['SQLALCHEMY_DATABASE_URI'] = PostgresORM.get_postgres_uri()
2020
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
2121

2222
db.init_app(app)

db.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,7 @@ def get_postgres_connection():
5656
)
5757
return conn
5858

59-
def get_postgres_uri():
60-
DB_HOST = os.getenv('POSTGRES_DB_HOST')
61-
DB_NAME = os.getenv('POSTGRES_DB_NAME')
62-
DB_USER = os.getenv('POSTGRES_DB_USER')
63-
DB_PASS = os.getenv('POSTGRES_DB_PASS')
64-
65-
return f'postgresql://{DB_USER}:{DB_PASS}@{DB_HOST}/{DB_NAME}'
59+
6660

6761
def postgres_query(query,params=None):
6862
conn = SupabaseInterface.get_postgres_connection()

query.py

+12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
from db import SupabaseInterface
22
from models import *
33
from sqlalchemy import func
4+
import os
5+
from dotenv import load_dotenv
46

7+
8+
load_dotenv()
59
class PostgresQuery:
610

711
def get_issue_query():
@@ -81,6 +85,14 @@ def get_pr_data(dmp_issue_id):
8185

8286

8387
class PostgresORM:
88+
89+
def get_postgres_uri():
90+
DB_HOST = os.getenv('POSTGRES_DB_HOST')
91+
DB_NAME = os.getenv('POSTGRES_DB_NAME')
92+
DB_USER = os.getenv('POSTGRES_DB_USER')
93+
DB_PASS = os.getenv('POSTGRES_DB_PASS')
94+
95+
return f'postgresql://{DB_USER}:{DB_PASS}@{DB_HOST}/{DB_NAME}'
8496

8597
def get_issue_query():
8698
results = (

0 commit comments

Comments
 (0)