import os
from models import db

# For compatibility with the complete app
db_session = db.session

def init_db(app=None):
    """Initialize the database"""
    if app:
        db.init_app(app)
        with app.app_context():
            db.create_all()

def shutdown_session(exception=None):
    """Remove the session on app shutdown"""
    db.session.remove()
