16 lines
379 B
Python
16 lines
379 B
Python
|
from sqlmodel import SQLModel, create_engine, Session, select
|
||
|
|
||
|
sqlite_file_name = "database.db"
|
||
|
sqlite_url = f"sqlite:///{sqlite_file_name}"
|
||
|
|
||
|
engine = create_engine(sqlite_url, echo=False, connect_args={"check_same_thread": False})
|
||
|
|
||
|
|
||
|
def create_db_and_tables():
|
||
|
SQLModel.metadata.create_all(engine)
|
||
|
|
||
|
def get_session():
|
||
|
with Session(engine) as s:
|
||
|
yield s
|
||
|
|