Skip to content

Commit 9b0cae5

Browse files
committed
Change DB_URL config value to just DB and simplify scheme.
1 parent dee82b1 commit 9b0cae5

6 files changed

Lines changed: 20 additions & 11 deletions

File tree

bbblb/api/__init__.py

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

1818
@asynccontextmanager
1919
async def lifespan(app: Starlette):
20-
await model.init_engine(config.DB_URI, echo=False)
20+
await model.init_engine(config.DB, echo=False)
2121
poll_worker = poller.Poller()
2222
importer = recordings.RecordingImporter(
2323
basedir=pathlib.Path(config.RECORDING_PATH),

bbblb/model.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ def utcnow():
6262

6363
async def init_engine(db: str, echo=False):
6464
global async_engine, AsyncSessionMaker, ScopedSession
65+
66+
if db.startswith("sqlite://"):
67+
db = db.replace("sqlite://", "sqlite+aiosqlite://")
68+
elif db.startswith("postgres://"):
69+
db = db.replace("postgres://", "postgres+asyncpg://")
70+
6571
async_engine = create_async_engine(db, echo=echo)
6672
AsyncSessionMaker = async_sessionmaker(async_engine, expire_on_commit=False)
6773

bbblb/settings.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,10 @@ def __getattr__(self, name: str):
137137

138138

139139
class BBBLBConfig(BaseConfig):
140-
#: An sqlalchemy-style database URL. MUST be an async-capable engine
141-
#: Supportet are sqlite+aiosqlite:// and postgresql+asyncpg:// schemes.
142-
DB_URI: str
140+
#: An sqlalchemy compatible database connection string, starting with either
141+
#: `sqlite://` or `postgresql://`. For example `sqlite:////path/to/file.db`
142+
#: or `postgresql://user:pass@host/name`.
143+
DB: str
143144

144145
#: Primary domain for this service. This will be added as bbblb-origin
145146
#: metadata to meetings and is used by e.g. the recording upload script

docs/config.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ See `examples/bbblb.env.example` for a full list.
1313
The options here are lossely ordered by topic.
1414

1515
<!-- snip_start -->
16-
`DB_URI` (type: `str`, **REQUIRED**)
17-
An sqlalchemy-style database URL. MUST be an async-capable engine
18-
Supportet are sqlite+aiosqlite:// and postgresql+asyncpg:// schemes.
16+
`DB` (type: `str`, **REQUIRED**)
17+
An sqlalchemy compatible database connection string, starting with either
18+
`sqlite://` or `postgresql://`. For example `sqlite:////path/to/file.db`
19+
or `postgresql://user:pass@host/name`.
1920

2021
`DOMAIN` (type: `str`, **REQUIRED**)
2122
Primary domain for this service. This will be added as bbblb-origin

examples/bbblb.env.example

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# An sqlalchemy-style database URL. MUST be an async-capable engine
2-
# Supportet are sqlite+aiosqlite:// and postgresql+asyncpg:// schemes.
1+
# An sqlalchemy compatible database connection string, starting with either
2+
# `sqlite://` or `postgresql://`. For example `sqlite:////path/to/file.db`
3+
# or `postgresql://user:pass@host/name`.
34
# (REQUIRED; type: str)
4-
#BBBLB_DB_URI=
5+
#BBBLB_DB=
56

67
# Primary domain for this service. This will be added as bbblb-origin
78
# metadata to meetings and is used by e.g. the recording upload script

examples/compose/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
target: app
1010
restart: unless-stopped
1111
environment:
12-
- BBBLB_DB=postgresql+asyncpg://bbblb:bbblb@postgres/bbblb
12+
- BBBLB_DB=postgresql://bbblb:bbblb@postgres/bbblb
1313
- BBBLB_RECORDING_PATH=/data/recordings
1414
volumes:
1515
- ./data/recordings:/data/recordings

0 commit comments

Comments
 (0)