Skip to content

connection

Connection Objects

class Connection(ABC)

execute

@abstractmethod
def execute(query: str, parameters: Dict[str, Any] = {}) -> None

Executes Cypher query without returning any results.

execute_and_fetch

@abstractmethod
def execute_and_fetch(
        query: str,
        parameters: Dict[str, Any] = {}) -> Iterator[Dict[str, Any]]

Executes Cypher query and returns iterator of results.

is_active

@abstractmethod
def is_active() -> bool

Returns True if connection is active and can be used.

MemgraphConnection Objects

class MemgraphConnection(Connection)

execute

@database_error_handler
def execute(query: str, parameters: Dict[str, Any] = {}) -> None

Executes Cypher query without returning any results.

execute_and_fetch

@database_error_handler
def execute_and_fetch(
        query: str,
        parameters: Dict[str, Any] = {}) -> Iterator[Dict[str, Any]]

Executes Cypher query and returns iterator of results.

is_active

def is_active() -> bool

Returns True if connection is active and can be used.

_RoutedTransaction Objects

class _RoutedTransaction()

The object handed to an execute_read / execute_write work function.

Wraps the pymgclient cursor of a managed transaction and exposes the same execute / execute_and_fetch surface as class MemgraphConnection(), converting rows to gqlalchemy values. The surrounding transaction is managed by the router (begun, committed and retried around the work), so the work must not commit or roll back itself.

execute

def execute(query: str, parameters: Dict[str, Any] = {}) -> None

Executes Cypher query without returning any results.

execute_and_fetch

def execute_and_fetch(
        query: str,
        parameters: Dict[str, Any] = {}) -> Iterator[Dict[str, Any]]

Executes Cypher query and returns iterator of results.

Neo4jConnection Objects

class Neo4jConnection(Connection)

execute

def execute(query: str, parameters: Dict[str, Any] = {}) -> None

Executes Cypher query without returning any results.

execute_and_fetch

def execute_and_fetch(
        query: str,
        parameters: Dict[str, Any] = {}) -> Iterator[Dict[str, Any]]

Executes Cypher query and returns iterator of results.

is_active

def is_active() -> bool

Returns True if connection is active and can be used.