add db
This commit is contained in:
15
db.py
Normal file
15
db.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from typing import List
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from models.orm import Prompt
|
||||
|
||||
|
||||
class DB:
|
||||
def __init__(self, db: str = "sqlite:///example.db"):
|
||||
self.engine = create_engine(
|
||||
db, connect_args={"check_same_thread": False})
|
||||
|
||||
def get_prompts(self) -> List[Prompt]:
|
||||
with Session(self.engine) as session:
|
||||
return session.query(Prompt).all()
|
||||
Reference in New Issue
Block a user