Ejemplo n.º 1
0
 def insert_dataset_source(self, classifier, dataset_id, source_dataset_id):
     try:
         self._connection.execute(DATASET_SOURCE.insert(),
                                  classifier=classifier,
                                  dataset_ref=dataset_id,
                                  source_dataset_ref=source_dataset_id)
     except IntegrityError as e:
         if e.orig.pgcode == PGCODE_UNIQUE_CONSTRAINT:
             raise DuplicateRecordError('Source already exists')
         if e.orig.pgcode == PGCODE_FOREIGN_KEY_VIOLATION:
             raise MissingRecordError(
                 "Referenced source dataset doesn't exist")
         raise
Ejemplo n.º 2
0
 def insert_dataset_source(self, classifier, dataset_id, source_dataset_id):
     try:
         r = self._connection.execute(
             insert(DATASET_SOURCE).on_conflict_do_nothing(
                 index_elements=['classifier', 'dataset_ref']),
             classifier=classifier,
             dataset_ref=dataset_id,
             source_dataset_ref=source_dataset_id)
         return r.rowcount > 0
     except IntegrityError as e:
         if e.orig.pgcode == PGCODE_FOREIGN_KEY_VIOLATION:
             raise MissingRecordError(
                 "Referenced source dataset doesn't exist")
         raise