swh.core.db.common module#

swh.core.db.common.remove_kwargs(names)[source]#
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 and db keyword argument

Client options are passed as set options to the postgresql server. If available, decorated self.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 given client_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 the self.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 and db keyword argument

Client options are passed as set options to the postgresql server. If available, decorated self.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 given client_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 the self.query_options attribute filled from a config file).