Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr_SYX committed Jun 25, 2024
1 parent 8670251 commit bc93ad5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyerm/database/dbbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def __init__(self, db:Database, table_name:str, columns:dict=None) -> None:
for column, definition in list(columns.items()):
if 'VIRTUAL' in definition:
del columns[column.replace(' ', '_')]
assert columns is None or list(columns.keys()) == list([column[1] for column in self.db.cursor.execute(f'PRAGMA table_info({table_name})').fetchall()]), f'Columns do not match for table {table_name}, consider to check or change table name'
assert columns is None or list([col for col in columns.keys() if not str(col).startswith("image_")]) == \
list([column[1] for column in self.db.cursor.execute(f'PRAGMA table_info({table_name})').fetchall() if not str(column[1]).startswith("image_")]), \
f'Columns(except images) do not match for table {table_name}, consider to check or change table name'
if self.db.info:
print(f'Table {table_name} already exists')
self.primary_key = [column[1] for column in self.db.cursor.execute(f'PRAGMA table_info({table_name})').fetchall() if column[5] == 1]
Expand Down

0 comments on commit bc93ad5

Please sign in to comment.