Uow
uow
¶
Defines a Unit Of Work exposing the Repos that
abstract queries for kotobase's database
UOW
-
The
UnitOfWorkowns a single database session for the duration of awithblock and hands off that session for the repositories to use -
Repositories never open their own session, they share the one held by the unit of work, which keeps every query in an operation within a single consistent read
UnitOfWork
¶
Context manager that holds one session and its repositories
Attributes:
| Name | Type | Description |
|---|---|---|
session |
Session | None
|
The active session inside the |
audio
property
¶
Repository for pronunciation audio
Returns:
| Type | Description |
|---|---|
AudioRepo
|
An audio repository bound to the active session |
furigana
property
¶
Repository for furigana segmentation
Returns:
| Type | Description |
|---|---|
FuriganaRepo
|
A furigana repository bound to the active session |
jlpt
property
¶
Repository for the Tanos JLPT lists
Returns:
| Type | Description |
|---|---|
JLPTRepo
|
A JLPT repository bound to the active session |
jmdict
property
¶
Repository for JMdict entries
Returns:
| Type | Description |
|---|---|
JMDictRepo
|
A JMdict repository bound to the active session |
jmnedict
property
¶
Repository for JMnedict proper names
Returns:
| Type | Description |
|---|---|
JMNeDictRepo
|
A JMnedict repository bound to the active session |
kanji
property
¶
Repository for kanji
Returns:
| Type | Description |
|---|---|
KanjiRepo
|
A kanji repository bound to the active session |
radicals
property
¶
Repository for radicals and radical search
Returns:
| Type | Description |
|---|---|
RadicalRepo
|
A radical repository bound to the active session |
sentences
property
¶
Repository for Tatoeba example sentences
Returns:
| Type | Description |
|---|---|
SentenceRepo
|
A sentence repository bound to the active session |
tags
property
¶
Repository for the tag dictionary
Returns:
| Type | Description |
|---|---|
TagRepo
|
A tag repository bound to the active session |
__enter__()
¶
__exit__(exc_type, exc, traceback)
¶
Close the session and leave the context
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exc_type
|
type[BaseException] | None
|
Exception type if one was raised inside the context |
required |
exc
|
BaseException | None
|
Exception instance if one was raised |
required |
traceback
|
TracebackType | None
|
Traceback if one was raised |
required |
__init__(session_factory=None)
¶
Create a unit of work
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_factory
|
sessionmaker[Session] | None
|
Factory used to open the session, defaulting to the shared read-only factory |
None
|