Commit 2f609eef authored by Beno Sons's avatar Beno Sons

.env DB

parent 29ad9f84
......@@ -17,6 +17,12 @@ PORT=8000
-----------------------------
SECRET_KEY=your-secret-key
DATABASE_URL=postgresql://postgres:khansia215758@30.10.20.102/BUILDER
DATABASE_NAME=BUILDER
DB_USERNAME=postgres
DB_PASSWORD=khansia215758
DB_HOST=30.10.20.102
DB_PORT=5432
DATABASE_SCHEMA=gen_application_31
JWT_SECRET_KEY=your-jwt-secret-key
FLASK_APP=run.py
FLASK_ENV=development
......
......@@ -6,7 +6,7 @@ load_dotenv()
class Config:
SECRET_KEY = os.getenv('SECRET_KEY', 'mysecretkey')
SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL', 'postgresql://user:password@localhost/dbname')
SQLALCHEMY_DATABASE_URI = f"postgresql://{os.getenv('DB_USERNAME')}:{os.getenv('DB_PASSWORD')}@{os.getenv('DB_HOST')}:{os.getenv('DB_PORT')}/{os.getenv('DATABASE_NAME')}"
SCHEMA_NAME = os.getenv('DATABASE_SCHEMA')
SQLALCHEMY_TRACK_MODIFICATIONS = False
DEBUG = os.getenv('FLASK_ENV') == 'development'
......
#!/usr/bin/python
import psycopg2
from configparser import ConfigParser
from dotenv import load_dotenv
class connection():
......@@ -59,14 +59,13 @@ class connection():
try:
# read connection parameters
conn = psycopg2.connect(
database = "BUILDER",
user = "postgres",
password = "khansia215758",
host = "103.126.28.68",
port = "8082"
database = os.getenv('DATABASE_NAME'),
user = os.getenv('DB_USERNAME'),
password = os.getenv('DB_PASSWORD'),
host = os.getenv('DB_HOST'),
port = os.getenv('DB_PORT')
)
except (Exception, psycopg2.DatabaseError) as error:
print(error)
finally:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment