Add configurable database path via environment variables
- Add DATABASE_PATH environment variable support in app.py and aerich_config.py - DATABASE_PATH: For simple relative/absolute paths (default: database/raggr.db) - DATABASE_URL: For full connection strings (overrides DATABASE_PATH if set) - Create .env.example with all configuration options documented - Maintains backward compatibility with default database location Usage: # Use default path python app.py # Use custom path for development DATABASE_PATH=dev.db python app.py # Use full connection string DATABASE_URL=sqlite://custom/path.db python app.py 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import os
|
||||
|
||||
# Database configuration with environment variable support
|
||||
# Use DATABASE_PATH for relative paths or DATABASE_URL for full connection strings
|
||||
DATABASE_PATH = os.getenv("DATABASE_PATH", "database/raggr.db")
|
||||
DATABASE_URL = os.getenv("DATABASE_URL", f"sqlite://{DATABASE_PATH}")
|
||||
|
||||
TORTOISE_ORM = {
|
||||
"connections": {"default": os.getenv("DATABASE_URL", "sqlite:///app/database/raggr.db")},
|
||||
"connections": {"default": DATABASE_URL},
|
||||
"apps": {
|
||||
"models": {
|
||||
"models": [
|
||||
|
||||
Reference in New Issue
Block a user