Skip to content

Commit f3523df

Browse files
committed
💿 Change the POSTGRES_DB_URI to DATABASE_URL
1 parent 1362a74 commit f3523df

File tree

9 files changed

+20
-10
lines changed

9 files changed

+20
-10
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ Now you're ready to start using Whitebox! Read the [documentation](https://squar
7171

7272
# Set up locally for development
7373

74+
Whitebox supports Postgres and SQLite. You can use either one of them.
75+
If you want to use SQLite, you need to set up a SQLite database and set the `DATABASE_URL` environment variable to the database URL.
76+
If you want to use Postgres, you don't need to do anything. Just have a Postgres database running and set the `DATABASE_URL` environment variable to the database URL.
77+
7478
### Install packages:
7579

7680
```bash
@@ -85,6 +89,12 @@ pre-commit install
8589
ENV=dev uvicorn whitebox.main:app --reload
8690
```
8791

92+
### Quick way to start a postgres database:
93+
94+
```bash
95+
docker compose up postgres -d
96+
```
97+
8898
### Tests:
8999

90100
- Run: `ENV=test pytest` or `ENV=test pytest -s` to preserve logs.

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ services:
2222
restart: unless-stopped
2323
environment:
2424
- APP_NAME=Whitebox | Docker
25-
- POSTGRES_DB_URI=postgresql://postgres:postgres@postgres:5432/postgres
25+
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/postgres
2626
ports:
2727
- "8000:8000"
2828
depends_on:

docs/mkdocs/docs/tutorial/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ services:
5151
restart: unless-stopped
5252
environment:
5353
- APP_NAME=Whitebox | Docker
54-
- POSTGRES_DB_URI=postgresql://postgres:postgres@postgres:5432/postgres
54+
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/postgres
5555
ports:
5656
- "8000:8000"
5757
depends_on:

helm_charts/whitebox/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spec:
3030
containerPort: 8000
3131
protocol: TCP
3232
env:
33-
- name: POSTGRES_DB_URI
33+
- name: DATABASE_URL
3434
value: postgresql://{{ .Values.postgresql.auth.username | default "postgres" }}:{{ .Values.postgresql.auth.password | default "postgres" }}@{{ .Release.Name }}-postgresql/postgres
3535
resources:
3636
{{- toYaml .Values.resources | nindent 12 }}

whitebox/core/db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
from secrets import token_hex
1414

1515
settings = get_settings()
16-
database = databases.Database(settings.POSTGRES_DB_URI)
17-
engine = sqlalchemy.create_engine(settings.POSTGRES_DB_URI)
16+
database = databases.Database(settings.DATABASE_URL)
17+
engine = sqlalchemy.create_engine(settings.DATABASE_URL)
1818
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
1919

2020

whitebox/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class Settings(BaseSettings):
77
APP_NAME: str = ""
88
ENV: str = ""
9-
POSTGRES_DB_URI: str = ""
9+
DATABASE_URL: str = ""
1010
VERSION: str = ""
1111
MODEL_PATH: str = ""
1212

whitebox/cron_tasks/monitoring_alerts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
settings = get_settings()
1919

20-
engine = create_engine(settings.POSTGRES_DB_URI)
20+
engine = create_engine(settings.DATABASE_URL)
2121
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
2222
db: Session = SessionLocal()
2323

whitebox/cron_tasks/monitoring_metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
settings = get_settings()
2929

30-
engine = create_engine(settings.POSTGRES_DB_URI)
30+
engine = create_engine(settings.DATABASE_URL)
3131
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
3232
db: Session = SessionLocal()
3333

whitebox/tests/v1/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def client():
2727
@fixture(scope="session", autouse=True)
2828
async def db():
2929
# runs once before all tests
30-
engine = sqlalchemy.create_engine(settings.POSTGRES_DB_URI)
31-
database = databases.Database(settings.POSTGRES_DB_URI)
30+
engine = sqlalchemy.create_engine(settings.DATABASE_URL)
31+
database = databases.Database(settings.DATABASE_URL)
3232
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
3333
Base.metadata.create_all(engine)
3434
await database.connect()

0 commit comments

Comments
 (0)