You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
424 B
Python
13 lines
424 B
Python
|
1 day ago
|
from sqlmodel import SQLModel, Session, create_engine
|
||
|
|
from app.core.config import settings
|
||
|
|
|
||
|
|
connect_args = {"check_same_thread": False} if settings.DATABASE_URL.startswith("sqlite") else {}
|
||
|
|
engine = create_engine(settings.DATABASE_URL, echo=False, connect_args=connect_args)
|
||
|
|
|
||
|
|
def create_db_and_tables():
|
||
|
|
SQLModel.metadata.create_all(engine)
|
||
|
|
|
||
|
|
def get_session():
|
||
|
|
with Session(engine) as session:
|
||
|
|
yield session
|