Skip to content

Commit

Permalink
Allow overriding default database connection string with DATABASE_URL…
Browse files Browse the repository at this point in the history
… env variable
  • Loading branch information
jrauha committed Jan 16, 2024
1 parent 3823d05 commit 6c1462e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def _parse_bool(value, default=False):


def build_database_uri():
url = environ.get("DATABASE_URL")
if url:
return url.replace("postgres://", "postgresql://", 1)

user = environ.get("POSTGRES_USER") or "postgres"
password = environ.get("POSTGRES_PASSWORD") or "postgres"
host = environ.get("POSTGRES_HOST") or "localhost"
Expand Down

0 comments on commit 6c1462e

Please sign in to comment.