Exemplo n.º 1
0
def get_or_create_entity(conn, dn):
    try:
        entity = get_entity(conn, dn)
    except NoSuchEntityError:
        entity = create_entity(conn, dn)

    return entity
Exemplo n.º 2
0
    def store_raw(self, datasource, raw_datapackage):
        if not raw_datapackage.is_empty():
            with closing(self.conn.cursor()) as cursor:
                datapackage = raw_datapackage.refine(cursor)

            self.conn.commit()

            dn = raw_datapackage.rows[0][0]
            entity = get_entity(self.conn, dn)
            entitytype = get_entitytype_by_id(self.conn, entity.entitytype_id)

            self.store(datasource, entitytype, datapackage)