swh.core.db.common module#
- swh.core.db.common.apply_options(cursor, options)[source]#
Applies the given postgresql client options to the given cursor.
Returns a dictionary with the old values if they changed.
- swh.core.db.common.db_transaction(**client_options)[source]#
decorator to execute Backend methods within DB transactions
The decorated method must accept a
cur
anddb
keyword argumentClient options are passed as
set
options to the postgresql server. If available, decoratedself.query_options
can be defined as a dict which keys are (decorated) method names and values are dicts. These later dicts are merged with the givenclient_options
. So it’s possible to define default client_options as decorator arguments and overload them from e.g. a configuration file (e.g. making is theself.query_options
attribute filled from a config file).
- swh.core.db.common.db_transaction_generator(**client_options)[source]#
decorator to execute Backend methods within DB transactions, while returning a generator
The decorated method must accept a
cur
anddb
keyword argumentClient options are passed as
set
options to the postgresql server. If available, decoratedself.query_options
can be defined as a dict which keys are (decorated) method names and values are dicts. These later dicts are merged with the givenclient_options
. So it’s possible to define default client_options as decorator arguments and overload them from e.g. a configuration file (e.g. making is theself.query_options
attribute filled from a config file).