Skip to content

Commit

Permalink
Refact: get database_url settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jairojair committed Sep 26, 2018
1 parent ff98f55 commit 15bcea8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
12 changes: 4 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ services:
command: make

environment:
APP_ENV: dev

DB_HOST: database
DB_NAME: db
DB_USER: user
DB_PASS: secret

JWT_SECRET: DevSecret

- DATABASE_URL=postgres://user:secret@database:5432/db

- JWT_SECRET=DevSecret

database:
image: postgres:10-alpine
Expand Down
30 changes: 9 additions & 21 deletions featuren/settings.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
import os
import sys
import logging

from orator import Model
from orator import DatabaseManager
from py_database_url import orator

from decouple import config

DB_HOST = config("DB_HOST")
DB_NAME = config("DB_NAME")
DB_USER = config("DB_USER")
DB_PASS = config("DB_PASS")

jwt_settings = {"secret": config("JWT_SECRET"), "exp": 120, "algorithm": "HS256"}
database_settings = orator()

db = DatabaseManager(database_settings)
Model.set_connection_resolver(db)

DATABASES = {
"postgres": {
"driver": "postgres",
"host": DB_HOST,
"database": DB_NAME,
"user": DB_USER,
"password": DB_PASS,
"prefix": "",
}
jwt_settings = {
"secret": os.environ.get("JWT_SECRET"),
"exp": 120,
"algorithm": "HS256",
}


db = DatabaseManager(DATABASES)
Model.set_connection_resolver(db)

# Logs

formatter = "%(asctime)s - %(module)s - %(name)s - %(levelname)s - %(message)s"
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ python-decouple==3.1.0
PyJWT==1.6.4
passlib==1.7.1
mkdocs-material==3.0.4
py_database_url==0.0.4

0 comments on commit 15bcea8

Please sign in to comment.