25 lines
595 B
Python
25 lines
595 B
Python
"""
|
|
init_db.py
|
|
==========
|
|
Standalone script to create the SQLite database tables.
|
|
|
|
Run this once inside the container after deployment:
|
|
python init_db.py
|
|
|
|
Or use the registered Flask CLI command:
|
|
flask --app app init-db
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
|
|
# Ensure the project root is on sys.path so `from app import app` works.
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from app import app
|
|
from models import init_db
|
|
|
|
# Use the configured database path and create tables.
|
|
with app.app_context():
|
|
init_db()
|
|
print(f"Database initialized at {app.config['DATABASE']}")
|