[add]: Database connection and migrations
This commit is contained in:
+20
-1
@@ -5,6 +5,11 @@ from flask_cors import CORS
|
||||
from app.config import Config
|
||||
from app.api.routes import api
|
||||
from app.errors import register_error_handlers
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_migrate import Migrate
|
||||
|
||||
db = SQLAlchemy()
|
||||
migrate = Migrate()
|
||||
|
||||
def create_app():
|
||||
""" Factory function to create a Flask app instance """
|
||||
@@ -31,7 +36,21 @@ def create_app():
|
||||
# Error Handlers
|
||||
register_error_handlers(app)
|
||||
|
||||
|
||||
import logging
|
||||
from sqlalchemy import create_engine
|
||||
|
||||
# Set up logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Log the database URI
|
||||
logger.info(f"Database URI: {app.config['SQLALCHEMY_DATABASE_URI']}")
|
||||
|
||||
# Database and Migrations
|
||||
db.init_app(app)
|
||||
|
||||
|
||||
migrate.init_app(app, db)
|
||||
|
||||
|
||||
return app
|
||||
|
||||
Reference in New Issue
Block a user