# mayim.decorator

# Table of Contents

# hydrator

def hydrator(hydrator: Hydrator)

[view_source] (opens new window)

Convenience decorator to supply a specific hydrator to an executor method.

Example:

from mayim import Mayim, Executor, Hydrator, hydrator

class HydratorA(Hydrator):
    ...

class HydratorB(Hydrator):
    ...

class SomeExecuto(Executor):
    async def select_a(...) -> Something:
        ...

    @hydrator(HydratorB())
    async def select_b(...) -> Something:
        ...

Mayim(executors=[SomeExecutor(hydrator=HydratorA())])

Arguments:

  • hydrator Hydrator - The hydrator

# query

def query(query: str)

[view_source] (opens new window)

Convenience decorator to supply a query to an executor method without loading if from a source file.

Example:

from mayim import PostgresExecutor, query

class ItemExecutor(PostgresExecutor):
    @query(
        '''
        SELECT *
        FROM items
        WHERE item_id = $item_id;
        '''
    )
    async def select_item(self, item_id: int) -> Item:
        ...

Arguments:

  • query str - The query

# register

def register(cls)

[view_source] (opens new window)

Convenience decorator to preregister an executor

Example:

from mayim import PostgresExecutor, register

@register
class MyExecutor(PostgresExecutor):
    async def select_something(self) -> Something:
        ...