Skip to content

Commit

Permalink
fix(api): avoid config conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
BroKun committed Sep 16, 2024
1 parent bac5328 commit fb31421
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion api/dao/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from sqlalchemy.orm import Session
from models.account import AccountCreate, AccountORM, AccountStatus

from config import settings
from api_config import settings


class AccountHelper:
Expand Down
7 changes: 5 additions & 2 deletions api/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from typing import Generator
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker,Session
from sqlalchemy.orm import sessionmaker, Session

from config import settings
from api_config import settings

SQLALCHEMY_DATABASE_URL = str(settings.SQLALCHEMY_DATABASE_URI)

Expand All @@ -14,6 +14,8 @@
Base = declarative_base()

# 上下文管理器用于手动管理会话


@contextmanager
def get_session() -> Generator[Session, None, None]:
session = SessionLocal()
Expand All @@ -22,6 +24,7 @@ def get_session() -> Generator[Session, None, None]:
finally:
session.close()


def get_db():
try:
db = SessionLocal()
Expand Down
2 changes: 1 addition & 1 deletion api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from db import SessionLocal

from config import settings
from api_config import settings


with SessionLocal() as session:
Expand Down

0 comments on commit fb31421

Please sign in to comment.