adapters

어댑터 패턴 객체들이 정되된 모듈입니다.

orm

ORM 어댑터 모듈

class AbstractSession

세션의 일반적인 작업(commit, rollback) 을 추상화한 클래스.

abstract commit()

트랜잭션을 커밋합니다.

Return type

None

SessionMaker

Session 팩토리 타입.

alias of Callable[[], sqlalchemy.orm.session.Session]

clear_mappers()

ORM 매핑을 초기화 합니다.

Return type

None

get_scoped_session(engine)

with... 문으로 자동 리소스가 반환되는 세션을 리턴합니다.

Example:

with get_scoped_session() as db:
    batches = db.query(Batch).all()
    ...
Parameters

engine (Engine) – Engine.

Return type

Callable[[], AbstractContextManager[Session]]

get_session()

기본설정으로 SqlAlchemy Session 팩토리를 만듭니다.

Return type

Callable[[], Session]

init_engine(meta, url, connect_args=None, poolclass=None, show_log=False, isolation_level=None, drop_all=False)

ORM Engine을 초기화 합니다.

TODO: 상세 설명 추가.

Return type

Engine

start_mappers(use_exist=True)

도메인 객체들을 SqlAlchemy ORM 매퍼에 등록합니다.

Return type

MetaData

repository

레포지터리 패턴 구현.

class AbstractRepository

Bases: abc.ABC, contextlib.ContextDecorator

Repository 패턴의 추상 인터페이스 입니다.

abstract add(batch)

레포지터리에 Batch 객체를 추가합니다.

Return type

None

abstract clear()

레포지터리 내의 모든 엔티티 데이터를 지웁니다.

Return type

None

close()

레포지터리와 연결된 저장소 객체를 종료합니다.

Return type

None

abstract delete(item)

레포지터리에서 Batch 또는 OrdereLine 객체를 삭제합니다.

Return type

None

abstract get(reference='', **kwargs)

주어진 레퍼런스 문자열에 해당하는 Batch 객체를 조회합니다.

해당하는 배치를 못 찾을 경우 None 을 리턴합니다.

Return type

Optional[Batch]

abstract list()

모든 배치 객체 리스트를 조회합니다.

Return type

list[Batch]

class SqlAlchemyRepository(session)

Bases: app.adapters.repository.AbstractRepository

SqlAlchemy ORM을 저장소로 하는 AbstractRepository 구현입니다.

add(batch)

레포지터리에 Batch 객체를 추가합니다.

Return type

None

clear()

레포지터리 내의 모든 엔티티 데이터를 지웁니다.

Return type

None

close()

레포지터리와 연결된 저장소 객체를 종료합니다.

Return type

None

delete(item)

레포지터리에서 Batch 또는 OrdereLine 객체를 삭제합니다.

Return type

None

get(reference='', **kwargs)

주어진 레퍼런스 문자열에 해당하는 Batch 객체를 조회합니다.

해당하는 배치를 못 찾을 경우 None 을 리턴합니다.

Return type

Optional[Batch]

list()

모든 배치 객체 리스트를 조회합니다.

Return type

list[Batch]