Skip to content

Commit af9608e

Browse files
committed
Add new .env vatiables
1 parent c077d3f commit af9608e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

app/core/database.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
from sqlalchemy.ext.declarative import declarative_base
66
from sqlalchemy_utils import create_database, database_exists
77
from app.models import Base, Database
8+
import os
9+
import settings
810

9-
DATABASE_URL = 'postgresql://neelxie:password@localhost:5433/ccdatabase'
11+
service_database = os.getenv('DATABASE_URL')
12+
if not database_exists(service_database):
13+
create_database(service_database)
1014

11-
if not database_exists(DATABASE_URL):
12-
create_database(DATABASE_URL)
13-
14-
engine = create_engine(DATABASE_URL, pool_pre_ping=True)
15+
engine = create_engine(service_database, pool_pre_ping=True)
1516

1617
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
1718

0 commit comments

Comments
 (0)