Init Project Flexly Estimator
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import asyncio
|
||||
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
|
||||
from estimator.infra.db import Base, normalize_dsn
|
||||
|
||||
|
||||
def create_schema(dsn: str) -> None:
|
||||
"""Fresh tables for a test database (drops existing ones)."""
|
||||
|
||||
async def _go() -> None:
|
||||
engine = create_async_engine(normalize_dsn(dsn))
|
||||
try:
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.drop_all)
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
finally:
|
||||
await engine.dispose()
|
||||
|
||||
asyncio.run(_go())
|
||||
Reference in New Issue
Block a user