From b1a7b1a93f9715a5eed65dbfb62d4a8f3614290f Mon Sep 17 00:00:00 2001 From: inter Date: Mon, 8 Sep 2025 16:35:54 +0800 Subject: [PATCH] Add File --- backend/common/core/db.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 backend/common/core/db.py diff --git a/backend/common/core/db.py b/backend/common/core/db.py new file mode 100644 index 0000000..37eff29 --- /dev/null +++ b/backend/common/core/db.py @@ -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)