jameszokah commited on
Commit
505bbe5
·
1 Parent(s): d4255ec

Update database configuration and add application settings: change SQLite database path in alembic.ini and create a new config.py file for managing application settings with environment variables.

Browse files
Files changed (2) hide show
  1. alembic.ini +1 -1
  2. app/config.py +18 -0
alembic.ini CHANGED
@@ -44,7 +44,7 @@ version_path_separator = os
44
  # are written from script.py.mako
45
  output_encoding = utf-8
46
 
47
- sqlalchemy.url = sqlite:///app/storage/database.db
48
 
49
  [post_write_hooks]
50
  # post_write_hooks defines scripts or Python functions that are run
 
44
  # are written from script.py.mako
45
  output_encoding = utf-8
46
 
47
+ sqlalchemy.url = sqlite:///app/storage/audiobooks.db
48
 
49
  [post_write_hooks]
50
  # post_write_hooks defines scripts or Python functions that are run
app/config.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Application configuration."""
2
+ import os
3
+ from functools import lru_cache
4
+ from pydantic_settings import BaseSettings
5
+
6
+ class Settings(BaseSettings):
7
+ """Application settings."""
8
+ DATABASE_URL: str = os.getenv("DATABASE_URL", "sqlite:///app/storage/audiobooks.db")
9
+ STORAGE_PATH: str = os.getenv("STORAGE_PATH", "app/storage")
10
+
11
+ class Config:
12
+ """Pydantic config."""
13
+ env_file = ".env"
14
+
15
+ @lru_cache()
16
+ def get_settings() -> Settings:
17
+ """Get cached settings."""
18
+ return Settings()