X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fdb_base.py;h=26e4c002c96d92eb724c0125512cd4815055f0e6;hb=a92a0eaaf370c626b442863f4127cd11fc64754c;hp=4a877213d2689d3d4dd7ce73f1e4eb370c88cd6e;hpb=05a8b7bc29197345f9718796c110d6cf3c2ad176;p=osm%2FRO.git diff --git a/osm_ro/db_base.py b/osm_ro/db_base.py index 4a877213..26e4c002 100644 --- a/osm_ro/db_base.py +++ b/osm_ro/db_base.py @@ -336,7 +336,31 @@ class db_base(): self.logger.debug(cmd) self.cur.execute(cmd) return self.cur.rowcount - + + def _new_uuid(self, root_uuid=None, used_table=None, created_time=0): + """ + Generate a new uuid. It DOES NOT begin or end the transaction, so self.con.cursor must be created + :param root_uuid: master uuid of the transaction + :param used_table: the table this uuid is intended for + :param created_time: time of creation + :return: the created uuid + """ + + uuid = str(myUuid.uuid1()) + # defining root_uuid if not provided + if root_uuid is None: + root_uuid = uuid + if created_time: + created_at = created_time + else: + created_at = time.time() + # inserting new uuid + cmd = "INSERT INTO uuids (uuid, root_uuid, used_at, created_at) VALUES ('{:s}','{:s}','{:s}', {:f})".format( + uuid, root_uuid, used_table, created_at) + self.logger.debug(cmd) + self.cur.execute(cmd) + return uuid + def _new_row_internal(self, table, INSERT, add_uuid=False, root_uuid=None, created_time=0): ''' Add one row into a table. It DOES NOT begin or end the transaction, so self.con.cursor must be created Attribute