Connection#

class swordfish.connection.Connection(impl)#

A generic connection class that wraps various types of connection implementations.

Parameters:

impl (T)

final sql(sql, *, vars=None)#

Executes a SQL query.

Parameters:
  • sql (str) – The SQL query string to be executed.

  • vars (dict, optional) – A dictionary of variables to bind to the SQL query.

Returns:

The result of the SQL query execution.

Return type:

Constant

final close()#

Closes the connection.

final commit()#

Commits the current transaction.

Raises:

NotImplementedError – The commit operation is not implemented.

Return type:

None

final in_transaction()#

Checks whether the connection is in an active transaction context.

Returns:

True if in an active transaction context, False otherwise.

Return type:

bool

Raises:

NotImplementedError – The in_transaction operation is not implemented.

final rollback()#

Rolls back the current transaction.

Raises:

NotImplementedError – The rollback operation is not implemented.

Return type:

None