18 lines
407 B
Python
18 lines
407 B
Python
import random
|
|
import string
|
|
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
|
|
|