Skip to content

Commit

Permalink
Default DSN use LRU cache for optimization and to make warning come u…
Browse files Browse the repository at this point in the history
…p only once
  • Loading branch information
nb-programmer committed Nov 3, 2024
1 parent 437615d commit bcb7f42
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sample_fastapi/app/database/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from functools import lru_cache

from pydantic import Field

Expand All @@ -9,8 +10,11 @@
APP_DB_SESSION_MANAGER_KEY = "_dbsm" # Lol


@lru_cache()
def _default_db_dsn():
LOG.warning("Using SQLite In-memory database as `database_url` config was not specified. Content WILL be lost after shutting down the app!")
LOG.warning(
"Using SQLite In-memory database as `database_url` config was not specified. Content WILL be lost after shutting down the app!"
)
return "sqlite+aiosqlite:///:memory:"


Expand Down

0 comments on commit bcb7f42

Please sign in to comment.