From d7ff75db61d4d9b3687caaea65c941545d88c1dd Mon Sep 17 00:00:00 2001 From: Rico Hermans Date: Mon, 15 Apr 2024 11:19:22 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20Make=20download=20script=20error?= =?UTF-8?q?=20and=20continue=20(#5411)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The download script doesn't deal well with maps, but at least we can make it catch the error and continue. --- tools/download-database.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/download-database.py b/tools/download-database.py index 2a8f51d2183..0507c856d11 100644 --- a/tools/download-database.py +++ b/tools/download-database.py @@ -96,7 +96,13 @@ def insert_table(self, table_name): table.key_columns + [onetomanycol] if listcol.type.is_set else []) print(onetomanytable.table_name) cursor.execute(onetomanytable.drop_statement) - cursor.execute(onetomanytable.create_statement) + try: + # The `classes` table contains a list of objects, which this script can't + # deal with. Catch the error, but continue. + cursor.execute(onetomanytable.create_statement) + except Exception as e: + print(f'Dropping column {listcol.name} (running \'{onetomanytable.create_statement}\' leads to {e})') + continue one_to_many_data = [] for row in table_data['rows']: @@ -110,7 +116,7 @@ def insert_table(self, table_name): # Maps (not implemented yet) for mapcol in (col for col in columns if col.type.is_map): - print(f'Dropping column: {table.original_name}.{mapcol.original_name}') + print(f'Dropping column: {table.original_name}.{mapcol.original_name} (no support for map columns)') self.db.commit()