Initial commit
This commit is contained in:
commit
25ba7968d5
7 changed files with 381 additions and 0 deletions
15
src/random_access/db.py
Normal file
15
src/random_access/db.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from sqlmodel import SQLModel, create_engine, Session
|
||||
|
||||
DATABASE_URL = "sqlite:////home/micha/Documents/random-access/database.db" # sync SQLite URL
|
||||
|
||||
# connect_args needed for SQLite to allow multithreaded access
|
||||
connect_args = {"check_same_thread": False}
|
||||
|
||||
engine = create_engine(DATABASE_URL, echo=True, connect_args=connect_args)
|
||||
|
||||
def init_db():
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
def get_session():
|
||||
with Session(engine) as session:
|
||||
yield session
|
||||
Loading…
Add table
Add a link
Reference in a new issue