def update_tile_footprint(self): """Update the tile footprint entry in the database""" if not self.db.tile_footprint_exists(self.tile_dict): # We may need to create a new footprint record. footprint_dict = {'x_index': self.tile_footprint[0], 'y_index': self.tile_footprint[1], 'tile_type_id': self.tile_type_id, 'x_min': self.tile_contents.tile_extents[0], 'y_min': self.tile_contents.tile_extents[1], 'x_max': self.tile_contents.tile_extents[2], 'y_max': self.tile_contents.tile_extents[3], 'bbox': 'Populate this within sql query?'} # Create an independent database connection for this transaction. my_db = IngestDBWrapper(self.datacube.create_connection()) try: with self.collection.transaction(my_db): if not my_db.tile_footprint_exists(self.tile_dict): my_db.insert_tile_footprint(footprint_dict) except psycopg2.IntegrityError: # If we get an IntegrityError we assume the tile_footprint # is already in the database, and we do not need to add it. pass finally: my_db.close()
def update_tile_footprint(self): """Update the tile footprint entry in the database""" if not self.db.tile_footprint_exists(self.tile_dict): # We may need to create a new footprint record. footprint_dict = { 'x_index': self.tile_footprint[0], 'y_index': self.tile_footprint[1], 'tile_type_id': self.tile_type_id, 'x_min': self.tile_contents.tile_extents[0], 'y_min': self.tile_contents.tile_extents[1], 'x_max': self.tile_contents.tile_extents[2], 'y_max': self.tile_contents.tile_extents[3], 'bbox': 'Populate this within sql query?' } # Create an independent database connection for this transaction. my_db = IngestDBWrapper(self.datacube.create_connection()) try: with self.collection.transaction(my_db): if not my_db.tile_footprint_exists(self.tile_dict): my_db.insert_tile_footprint(footprint_dict) except psycopg2.IntegrityError: # If we get an IntegrityError we assume the tile_footprint # is already in the database, and we do not need to add it. pass finally: my_db.close()