Connection#

class swordfish.connection.Connection(impl)#

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

参数:

impl (T)

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

Executes a SQL query.

参数:
  • sql (str) -- The SQL query string to be executed.

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

返回:

The result of the SQL query execution.

返回类型:

Constant

final close()#

Closes the connection.

final commit()#

Commits the current transaction.

抛出:

NotImplementedError -- The commit operation is not implemented.

返回类型:

None

final in_transaction()#

Checks whether the connection is in an active transaction context.

返回:

True if in an active transaction context, False otherwise.

返回类型:

bool

抛出:

NotImplementedError -- The in_transaction operation is not implemented.

final rollback()#

Rolls back the current transaction.

抛出:

NotImplementedError -- The rollback operation is not implemented.

返回类型:

None