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:
28
.env.example
Normal file
28
.env.example
Normal file
@@ -0,0 +1,28 @@
|
||||
# Database Configuration
|
||||
# Use DATABASE_PATH for simple relative/absolute paths (e.g., "database/raggr.db" or "dev.db")
|
||||
# Or use DATABASE_URL for full connection strings (e.g., "sqlite://database/raggr.db")
|
||||
DATABASE_PATH=database/raggr.db
|
||||
# DATABASE_URL=sqlite://database/raggr.db
|
||||
|
||||
# JWT Configuration
|
||||
JWT_SECRET_KEY=your-secret-key-here
|
||||
|
||||
# Paperless Configuration
|
||||
PAPERLESS_TOKEN=your-paperless-token
|
||||
BASE_URL=192.168.1.5:8000
|
||||
|
||||
# Ollama Configuration
|
||||
OLLAMA_URL=http://192.168.1.14:11434
|
||||
OLLAMA_HOST=http://192.168.1.14:11434
|
||||
|
||||
# ChromaDB Configuration
|
||||
CHROMADB_PATH=/path/to/chromadb
|
||||
|
||||
# OpenAI Configuration
|
||||
OPENAI_API_KEY=your-openai-api-key
|
||||
|
||||
# Immich Configuration
|
||||
IMMICH_URL=http://192.168.1.5:2283
|
||||
IMMICH_API_KEY=your-immich-api-key
|
||||
SEARCH_QUERY=simba cat
|
||||
DOWNLOAD_DIR=./simba_photos
|
||||
@@ -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": [
|
||||
|
||||
5
app.py
5
app.py
@@ -26,8 +26,11 @@ app.register_blueprint(blueprints.users.user_blueprint)
|
||||
app.register_blueprint(blueprints.conversation.conversation_blueprint)
|
||||
|
||||
|
||||
# Database configuration with environment variable support
|
||||
DATABASE_PATH = os.getenv("DATABASE_PATH", "database/raggr.db")
|
||||
|
||||
TORTOISE_CONFIG = {
|
||||
"connections": {"default": "sqlite://database/raggr.db"},
|
||||
"connections": {"default": f"sqlite://{DATABASE_PATH}"},
|
||||
"apps": {
|
||||
"models": {
|
||||
"models": [
|
||||
|
||||
Reference in New Issue
Block a user