Skip to content

Interfaces

amsdal_glue.interfaces.ConnectionPoolBase

Bases: ABC

Abstract base class for managing a pool of database connections.

Parameters:

Name Type Description Default
connection_class type[ConnectionBase]

The class of the connection to manage.

required
*args Any

Positional arguments to pass to the connection class.

()
**kwargs Any

Keyword arguments to pass to the connection class.

{}

Methods:

Name Description
get_connection

str | None = None) -> ConnectionBase: Retrieves a connection from the pool.

disconnect_connection

str | None = None) -> None: Disconnects a specific connection from the pool.

disconnect

Disconnects all connections in the pool.

is_connected abstractmethod property

is_connected

bool: Indicates if the pool is connected.

is_alive abstractmethod property

is_alive

bool: Indicates if the pool is alive.

get_connection abstractmethod

get_connection(transaction_id=None)

Retrieves a connection from the pool.

Parameters:

Name Type Description Default
transaction_id str | None

The transaction ID for the connection.

None

Returns:

Name Type Description
ConnectionBase ConnectionBase

The connection instance.

disconnect_connection abstractmethod

disconnect_connection(transaction_id=None)

Disconnects a specific connection from the pool.

Parameters:

Name Type Description Default
transaction_id str | None

The transaction ID for the connection.

None

disconnect abstractmethod

disconnect()

Disconnects all connections in the pool.

amsdal_glue.interfaces.ConnectionBase

Bases: Connectable, ABC

Abstract base class for database connections.

query abstractmethod

query(query)

Executes a query and returns the result.

Parameters:

Name Type Description Default
query QueryStatement

The query to execute.

required

Returns:

Type Description
list[Data]

list[Data]: The result of the query.

query_schema abstractmethod

query_schema(filters=None)

Queries the schema with optional filters.

Parameters:

Name Type Description Default
filters Conditions | None

Optional filters for the schema query.

None

Returns:

Type Description
list[Schema]

list[Schema]: The result of the schema query.

run_mutations abstractmethod

run_mutations(mutations)

Executes a list of data mutations.

Parameters:

Name Type Description Default
mutations list[DataMutation]

The list of data mutations to execute.

required

Returns:

Type Description
list[list[Data] | None]

list[list[Data] | None]: The result of the mutations.

acquire_lock abstractmethod

acquire_lock(lock)

Acquires a lock.

Parameters:

Name Type Description Default
lock ExecutionLockCommand

The lock command to execute.

required

Returns:

Name Type Description
Any Any

The result of the lock acquisition.

release_lock abstractmethod

release_lock(lock)

Releases a lock.

Parameters:

Name Type Description Default
lock ExecutionLockCommand

The lock command to execute.

required

Returns:

Name Type Description
Any Any

The result of the lock release.

commit_transaction abstractmethod

commit_transaction(transaction)

Commits a transaction.

Parameters:

Name Type Description Default
transaction TransactionCommand | str | None

The transaction to commit.

required

Returns:

Name Type Description
Any Any

The result of the transaction commit.

rollback_transaction abstractmethod

rollback_transaction(transaction)

Rolls back a transaction.

Parameters:

Name Type Description Default
transaction TransactionCommand | str | None

The transaction to roll back.

required

Returns:

Name Type Description
Any Any

The result of the transaction rollback.

begin_transaction abstractmethod

begin_transaction(transaction)

Begins a transaction.

Parameters:

Name Type Description Default
transaction TransactionCommand | str | None

The transaction to begin.

required

Returns:

Name Type Description
Any Any

The result of the transaction begin.

revert_transaction abstractmethod

revert_transaction(transaction)

Reverts a transaction.

Parameters:

Name Type Description Default
transaction TransactionCommand | str | None

The transaction to revert.

required

Returns:

Name Type Description
Any Any

The result of the transaction revert.

run_schema_command abstractmethod

run_schema_command(command)

Executes a schema command.

Parameters:

Name Type Description Default
command SchemaCommand

The schema command to execute.

required

Returns:

Type Description
list[Schema | None]

list[Schema | None]: The result of the schema command.

debug_queries property

debug_queries

Returns the debug queries flag.

Returns:

Name Type Description
bool bool

True if debug queries are enabled, False otherwise.

queries abstractmethod property

queries

Returns the queries executed on this connection.

Returns:

Type Description
list[str]

list[str]: The queries executed.

amsdal_glue.interfaces.Connectable

Bases: ABC

connect abstractmethod

connect(*args, **kwargs)

Connects to the database. :param kwargs: the connection parameters :type kwargs: Any

:return: None

disconnect abstractmethod

disconnect()

Disconnects from the database.

:return: None

is_connected abstractmethod property

is_connected

Checks if the connection is established.

:return: True if connected, False otherwise :rtype: bool

is_alive abstractmethod property

is_alive

Checks if the connection is alive.

:return: True if alive, False otherwise :rtype: bool