+ def new_rows(self, tables, uuid_list=None):
+ """
+ Make a transactional insertion of rows at several tables
+ :param tables: list with dictionary where the keys are the table names and the values are a row or row list
+ with the values to be inserted at the table. Each row is a dictionary with the key values. E.g.:
+ tables = [
+ {"table1": [ {"column1": value, "column2: value, ... }, {"column1": value, "column2: value, ... }, ...],
+ {"table2": [ {"column1": value, "column2: value, ... }, {"column1": value, "column2: value, ... }, ...],
+ {"table3": {"column1": value, "column2: value, ... }
+ }
+ If tables does not contain the 'created_at', it is generated incrementally with the order of tables. You can
+ provide a integer value, that it is an index multiply by 0.00001 to add to the created time to manually set
+ up and order
+ :param uuid_list: list of created uuids, first one is the root (#TODO to store at uuid table)
+ :return: None if success, raise exception otherwise
+ """
+ tries = 2
+ while tries:
+ created_time = time.time()
+ try:
+ with self.con:
+ self.cur = self.con.cursor()
+ for table in tables:
+ for table_name, row_list in table.items():
+ index = 0
+ if isinstance(row_list, dict):
+ row_list = (row_list, ) #create a list with the single value
+ for row in row_list:
+ if table_name in self.tables_with_created_field:
+ if "created_at" in row:
+ created_time_param = created_time + row.pop("created_at")*0.00001
+ else:
+ created_time_param = created_time + index*0.00001
+ index += 1
+ else:
+ created_time_param = 0
+ self._new_row_internal(table_name, row, add_uuid=False, root_uuid=None,
+ created_time=created_time_param)
+ return
+ except (mdb.Error, AttributeError) as e:
+ self._format_error(e, tries)
+ tries -= 1
+