Automated Action e852047583 Create Todo application with FastAPI and SQLite
- Implemented project structure
- Added SQLAlchemy models and database connection
- Created Alembic migrations
- Implemented CRUD API endpoints
- Added health endpoint
- Updated README.md

generated with BackendIM... (backend.im)
2025-05-13 06:15:34 +00:00

47 lines
1.2 KiB
Python

from logging.config import fileConfig
from sqlalchemy import engine_from_config
from sqlalchemy import pool
from alembic import context
from app.models import Base
from app.core.config import settings
config = context.config
fileConfig(config.config_file_name)
target_metadata = Base.metadata
# Set the SQLAlchemy URL from our settings
config.set_main_option("sqlalchemy.url", settings.SQLALCHEMY_DATABASE_URL)
def run_migrations_offline():
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online():
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata
)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()