diff options
Diffstat (limited to 'megapixels/app/models/sql_factory.py')
| -rw-r--r-- | megapixels/app/models/sql_factory.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/megapixels/app/models/sql_factory.py b/megapixels/app/models/sql_factory.py index 5cdaa889..eb91fb37 100644 --- a/megapixels/app/models/sql_factory.py +++ b/megapixels/app/models/sql_factory.py @@ -62,9 +62,10 @@ def load_sql_dataset(path, replace=False, engine=None, base_model=None): df = pd.read_csv(fn) # fix columns that are named "index", a sql reserved word df.reindex_axis(sorted(df.columns), axis=1) + print(df.columns) columns = [column.name for column in table.__table__.columns] - # print(columns) - df.columns = sorted(columns) + print(columns) + df.columns = columns df.to_sql(name=table.__tablename__, con=engine, if_exists='replace', index=False) return dataset @@ -121,7 +122,7 @@ class SqlDataset: identities = [] file_record_table = self.get_table('file_record') for row in identity_list: - file_record = file_record_table.query.filter(file_record_table.id == row.record_id).first() + file_record = file_record_table.query.filter(file_record_table.identity_id == row.id).first() identities.append({ 'file_record': file_record.toJSON(), 'identity': row.toJSON(), @@ -172,12 +173,12 @@ class SqlDataset: sha256 = Column(String(36, convert_unicode=True), nullable=False) subdir = Column(String(36, convert_unicode=True), nullable=False) uuid = Column(String(36, convert_unicode=True), nullable=False) - identity_index = Column(Integer) + identity_id = Column(Integer) def toJSON(self): return { 'id': self.id, 'uuid': self.uuid, - 'identity_index': self.identity_index, + 'identity_id': self.identity_id, } return FileRecord @@ -211,7 +212,7 @@ class SqlDataset: id = Column(Integer, primary_key=True) h = Column(Float, nullable=False) image_height = Column(Integer, nullable=False) - record_index = Column(Integer, nullable=False) + record_id = Column(Integer, nullable=False) image_width = Column(Integer, nullable=False) w = Column(Float, nullable=False) x = Column(Float, nullable=False) @@ -219,7 +220,7 @@ class SqlDataset: def toJSON(self): return { 'id': self.id, - 'record_index': self.record_index, + 'record_id': self.record_id, 'image_height': self.image_height, 'image_width': self.image_width, 'w': self.w, |
