Skip to content

Executors

Definition for query executors.

async_executor

Definition for creator of async executors.

AsyncExecutor (BaseExecutor)

Async executor for queries.

Source code in edgeql_queries/executors/async_executor.py
class AsyncExecutor(BaseExecutor):
    """Async executor for queries."""

    def __init__(self, query: Query) -> None:
        """Initialize an executor for query.

        Arguments:
            query: query for execution.
        """
        super().__init__()

        self._query = query
        self._executor = _OPERATION_TO_EXECUTOR[query.operation_type]

    def __call__(self, conn: AsyncIOExecutor, *args: Any, **kwargs: Any) -> Awaitable:
        """Execute query.

        Arguments:
            conn: asynchronous EdgeDB executor.
            args: positional arguments.
            kwargs: keyword arguments.

        Returns:
            Result of query execution.
        """
        return self._executor(self._query, conn, *args, **kwargs)

    def as_json(self) -> "AsyncExecutor":
        """Create an executor copy that will use JSON as output format.

        Returns:
            Copied executor.
        """
        executor = copy(self)
        executor._executor = _OPERATION_TO_JSON_EXECUTOR[self._query.operation_type]
        return executor

__call__(self, conn, *args, **kwargs) special

Execute query.

Parameters:

Name Type Description Default
conn AsyncIOExecutor

asynchronous EdgeDB executor.

required
args Any

positional arguments.

()
kwargs Any

keyword arguments.

{}

Returns:

Type Description
Awaitable

Result of query execution.

Source code in edgeql_queries/executors/async_executor.py
def __call__(self, conn: AsyncIOExecutor, *args: Any, **kwargs: Any) -> Awaitable:
    """Execute query.

    Arguments:
        conn: asynchronous EdgeDB executor.
        args: positional arguments.
        kwargs: keyword arguments.

    Returns:
        Result of query execution.
    """
    return self._executor(self._query, conn, *args, **kwargs)

__init__(self, query) special

Initialize an executor for query.

Parameters:

Name Type Description Default
query Query

query for execution.

required
Source code in edgeql_queries/executors/async_executor.py
def __init__(self, query: Query) -> None:
    """Initialize an executor for query.

    Arguments:
        query: query for execution.
    """
    super().__init__()

    self._query = query
    self._executor = _OPERATION_TO_EXECUTOR[query.operation_type]

as_json(self)

Create an executor copy that will use JSON as output format.

Returns:

Type Description
AsyncExecutor

Copied executor.

Source code in edgeql_queries/executors/async_executor.py
def as_json(self) -> "AsyncExecutor":
    """Create an executor copy that will use JSON as output format.

    Returns:
        Copied executor.
    """
    executor = copy(self)
    executor._executor = _OPERATION_TO_JSON_EXECUTOR[self._query.operation_type]
    return executor

base_executor

Definition for base executor.

BaseExecutor (ABC)

Base executor for queries.

Source code in edgeql_queries/executors/base_executor.py
class BaseExecutor(abc.ABC):
    """Base executor for queries."""

    @abc.abstractmethod
    def as_json(self: ExecutorT) -> ExecutorT:  # pragma: no cover
        """Create an executor copy that will use JSON as output format.

        Returns:
            Copied executor.
        """

as_json(self)

Create an executor copy that will use JSON as output format.

Returns:

Type Description
~ExecutorT

Copied executor.

Source code in edgeql_queries/executors/base_executor.py
@abc.abstractmethod
def as_json(self: ExecutorT) -> ExecutorT:  # pragma: no cover
    """Create an executor copy that will use JSON as output format.

    Returns:
        Copied executor.
    """

sync_executor

Definition for creator of sync executors.

SyncExecutor (BaseExecutor)

Sync executor for queries.

Source code in edgeql_queries/executors/sync_executor.py
class SyncExecutor(BaseExecutor):
    """Sync executor for queries."""

    def __init__(self, query: Query) -> None:
        """Initialize an executor for query.

        Arguments:
            query: query for execution.
        """
        super().__init__()

        self._query = query
        self._executor = _OPERATION_TO_EXECUTOR[query.operation_type]

    def __call__(self, conn: Executor, *args: Any, **kwargs: Any) -> Any:
        """Execute query.

        Arguments:
            conn: synchronous EdgeDB executor.
            args: positional arguments.
            kwargs: keyword arguments.

        Returns:
            Result of query execution.
        """
        return self._executor(self._query, conn, *args, **kwargs)

    def as_json(self) -> "SyncExecutor":
        """Create an executor copy that will use JSON as output format.

        Returns:
            Copied executor.
        """
        executor = copy(self)
        executor._executor = _OPERATION_TO_JSON_EXECUTOR[self._query.operation_type]
        return executor

__call__(self, conn, *args, **kwargs) special

Execute query.

Parameters:

Name Type Description Default
conn Executor

synchronous EdgeDB executor.

required
args Any

positional arguments.

()
kwargs Any

keyword arguments.

{}

Returns:

Type Description
Any

Result of query execution.

Source code in edgeql_queries/executors/sync_executor.py
def __call__(self, conn: Executor, *args: Any, **kwargs: Any) -> Any:
    """Execute query.

    Arguments:
        conn: synchronous EdgeDB executor.
        args: positional arguments.
        kwargs: keyword arguments.

    Returns:
        Result of query execution.
    """
    return self._executor(self._query, conn, *args, **kwargs)

__init__(self, query) special

Initialize an executor for query.

Parameters:

Name Type Description Default
query Query

query for execution.

required
Source code in edgeql_queries/executors/sync_executor.py
def __init__(self, query: Query) -> None:
    """Initialize an executor for query.

    Arguments:
        query: query for execution.
    """
    super().__init__()

    self._query = query
    self._executor = _OPERATION_TO_EXECUTOR[query.operation_type]

as_json(self)

Create an executor copy that will use JSON as output format.

Returns:

Type Description
SyncExecutor

Copied executor.

Source code in edgeql_queries/executors/sync_executor.py
def as_json(self) -> "SyncExecutor":
    """Create an executor copy that will use JSON as output format.

    Returns:
        Copied executor.
    """
    executor = copy(self)
    executor._executor = _OPERATION_TO_JSON_EXECUTOR[self._query.operation_type]
    return executor