Add File
This commit is contained in:
14
backend/common/core/db.py
Normal file
14
backend/common/core/db.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from sqlmodel import Session, create_engine, SQLModel
|
||||
|
||||
|
||||
from common.core.config import settings
|
||||
|
||||
|
||||
engine = create_engine(str(settings.SQLALCHEMY_DATABASE_URI))
|
||||
|
||||
def get_session():
|
||||
with Session(engine) as session:
|
||||
yield session
|
||||
|
||||
def init_db():
|
||||
SQLModel.metadata.create_all(engine)
|
||||
Reference in New Issue
Block a user