def store(self, column_names, fields, raw_data_rows): rows = list(raw_data_rows) raw_datapackage = RawDataPackage(column_names, rows) attributes = raw_datapackage.deduce_attributes() entity_ref = EntityDnRef(rows[0][0]) with closing(self.conn.cursor()) as cursor: datasource = DataSource.from_name(cursor, self.datasource) entitytype = entity_ref.get_entitytype(cursor) attributestore = AttributeStore.from_attributes( cursor, datasource, entitytype, attributes) self.conn.commit() attributestore.store_raw(raw_datapackage).run(self.conn)
def load_rawdatapackage(stream): return RawDataPackage.from_dict(json.load(stream))