Changeset View
Changeset View
Standalone View
Standalone View
swh/core/db/__init__.py
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | def transaction(self): | ||||
try: | try: | ||||
yield cur | yield cur | ||||
self.conn.commit() | self.conn.commit() | ||||
except Exception: | except Exception: | ||||
if not self.conn.closed: | if not self.conn.closed: | ||||
self.conn.rollback() | self.conn.rollback() | ||||
raise | raise | ||||
def copy_to(self, items, tblname, columns, default_values={}, | def copy_to(self, items, tblname, columns, | ||||
cur=None, item_cb=None): | cur=None, item_cb=None, default_values={}): | ||||
"""Copy items' entries to table tblname with columns information. | """Copy items' entries to table tblname with columns information. | ||||
Args: | Args: | ||||
items (dict): dictionary of data to copy over tblname. | items (dict): dictionary of data to copy over tblname. | ||||
tblname (str): destination table's name. | tblname (str): destination table's name. | ||||
columns ([str]): keys to access data in items and also the | columns ([str]): keys to access data in items and also the | ||||
column names in the destination table. | column names in the destination table. | ||||
default_values (dict): dictionnary of default values to use when | default_values (dict): dictionnary of default values to use when | ||||
Show All 33 Lines |