orghandbookapi.database.models package

Submodules

orghandbookapi.database.models.activity module

class orghandbookapi.database.models.activity.Activity(**kwargs)[source]

Bases: Base

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

_sa_class_manager = {'children': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'level': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'name': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'organizations': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'parent': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'parent_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}
children: Mapped[list[Activity]]
id: Mapped[int]
level: Mapped[int]
name: Mapped[str]
organizations: Mapped[list[Organization]]
parent: Mapped[Activity | None]
parent_id: Mapped[int | None]

orghandbookapi.database.models.base module

class orghandbookapi.database.models.base.Base(**kwargs: Any)[source]

Bases: DeclarativeBase

__init__(**kwargs: Any) None

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

_sa_registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

See also

orm_declarative_metadata

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

orghandbookapi.database.models.building module

class orghandbookapi.database.models.building.Building(**kwargs)[source]

Bases: Base

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

_sa_class_manager = {'address': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'latitude': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'longitude': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'organizations': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}
address: Mapped[str]
id: Mapped[int]
latitude: Mapped[float]
longitude: Mapped[float]
organizations: Mapped[list[Organization]]

orghandbookapi.database.models.organization module

class orghandbookapi.database.models.organization.Organization(**kwargs)[source]

Bases: Base

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

_sa_class_manager = {'activities': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'building': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'building_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'legal_name': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'phonenumbers': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}
activities: Mapped[list[Activity]]
building: Mapped[Building]
building_id: Mapped[int]
id: Mapped[int]
legal_name: Mapped[str]
phonenumbers: Mapped[list[PhoneNumber]]
class orghandbookapi.database.models.organization.PhoneNumber(**kwargs)[source]

Bases: Base

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

_sa_class_manager = {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'organization': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'organization_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'phone_number': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}
id: Mapped[int]
organization: Mapped[Organization]
organization_id: Mapped[int]
phone_number: Mapped[str]

orghandbookapi.database.models.repositories module

class orghandbookapi.database.models.repositories.ActivityRepository[source]

Bases: CRUDRepository

_abc_impl = <_abc._abc_data object>
async classmethod create(session: AsyncSession, model: BaseModel) Activity[source]
async classmethod delete(session: AsyncSession, id: int)[source]
async classmethod get(session: AsyncSession, id: int) Base | None[source]
async classmethod get_all(session: AsyncSession) list[Activity][source]
async classmethod get_tree(session: AsyncSession, parent_id: int | None = None) list[Activity][source]
async classmethod get_with_relations(session: AsyncSession, id: int) Activity | None[source]
async classmethod update(session: AsyncSession, model: BaseModel)[source]
class orghandbookapi.database.models.repositories.BuildingRepository[source]

Bases: CRUDRepository

_abc_impl = <_abc._abc_data object>
async classmethod create(session: AsyncSession, model: BaseModel) Building[source]
async classmethod delete(session: AsyncSession, id: int)[source]
async classmethod get(session: AsyncSession, id: int) Base | None[source]
async classmethod get_all(session: AsyncSession) list[Building][source]
async classmethod get_with_relations(session: AsyncSession, id: int) Building | None[source]
async classmethod update(session: AsyncSession, model: BaseModel)[source]
class orghandbookapi.database.models.repositories.CRUDRepository[source]

Bases: ABC

_abc_impl = <_abc._abc_data object>
abstractmethod async classmethod create(session: AsyncSession, model: BaseModel) Base[source]
abstractmethod async classmethod delete(session: AsyncSession, id: int)[source]
abstractmethod async classmethod get(session: AsyncSession, id: int) Base | None[source]
abstractmethod async classmethod get_all(session: AsyncSession) list[Base][source]
abstractmethod async classmethod get_with_relations(session: AsyncSession, id: int) Base | None[source]
abstractmethod async classmethod update(session: AsyncSession, model: BaseModel)[source]
class orghandbookapi.database.models.repositories.OrganizationRepository[source]

Bases: CRUDRepository

_abc_impl = <_abc._abc_data object>
async classmethod create(session: AsyncSession, model: BaseModel) Organization[source]
async classmethod delete(session: AsyncSession, id: int)[source]
async classmethod get(session: AsyncSession, id: int) Base | None[source]
async classmethod get_all(session: AsyncSession) list[Organization][source]
async classmethod get_by_activity(session: AsyncSession, activity_id: int) list[Organization][source]
async classmethod get_by_building(session: AsyncSession, building_id: int) list[Organization][source]
async classmethod get_in_radius(session: AsyncSession, lat: float, lon: float, radius_km: float) list[Organization][source]
async classmethod get_in_rectangular_area(session: AsyncSession, min_lat: float, max_lat: float, min_lon: float, max_lon: float) list[Organization][source]
async classmethod get_with_relations(session: AsyncSession, id: int) Organization | None[source]
async classmethod search_by_name(session: AsyncSession, name: str) list[Organization][source]
async classmethod update(session: AsyncSession, model: BaseModel) Organization[source]
async orghandbookapi.database.models.repositories.commit_process_session(session: AsyncSession, candidate: Any = None, *, flush: bool = False)[source]

Module contents

class orghandbookapi.database.models.Activity(**kwargs)[source]

Bases: Base

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

_sa_class_manager = {'children': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'level': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'name': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'organizations': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'parent': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'parent_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}
children: Mapped[list[Activity]]
id: Mapped[int]
level: Mapped[int]
name: Mapped[str]
organizations: Mapped[list[Organization]]
parent: Mapped[Activity | None]
parent_id: Mapped[int | None]
class orghandbookapi.database.models.Building(**kwargs)[source]

Bases: Base

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

_sa_class_manager = {'address': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'latitude': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'longitude': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'organizations': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}
address: Mapped[str]
id: Mapped[int]
latitude: Mapped[float]
longitude: Mapped[float]
organizations: Mapped[list[Organization]]
class orghandbookapi.database.models.Organization(**kwargs)[source]

Bases: Base

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

_sa_class_manager = {'activities': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'building': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'building_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'legal_name': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'phonenumbers': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}
activities: Mapped[list[Activity]]
building: Mapped[Building]
building_id: Mapped[int]
id: Mapped[int]
legal_name: Mapped[str]
phonenumbers: Mapped[list[PhoneNumber]]
class orghandbookapi.database.models.PhoneNumber(**kwargs)[source]

Bases: Base

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

_sa_class_manager = {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'organization': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'organization_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'phone_number': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}
id: Mapped[int]
organization: Mapped[Organization]
organization_id: Mapped[int]
phone_number: Mapped[str]