From 78bc68395fa584a78016ca3399a310b159e8800a Mon Sep 17 00:00:00 2001 From: Bence Luzsinszky <111147372+benceluzsinszky@users.noreply.github.com> Date: Sun, 6 Oct 2024 23:21:19 +0200 Subject: [PATCH] Add 0 default to max and min id (#246) The script crashes if the DB is empty, as max_id and min_id is None and the loop can't iterate on them. --- tools/mysql_to_elastic.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/mysql_to_elastic.py b/tools/mysql_to_elastic.py index de1ed64e..fa73601b 100644 --- a/tools/mysql_to_elastic.py +++ b/tools/mysql_to_elastic.py @@ -27,6 +27,12 @@ def main(starting_index): max_id = session.query(func.max(Article.id)).first()[0] min_id = session.query(func.min(Article.id)).first()[0] + + if max_id is None: + max_id = 0 + if min_id is None: + min_id = 0 + print(f"starting import at: {starting_index}") print(f"max id in db: {max_id}")