diff options
Diffstat (limited to 'app/func/remove_old_data.py')
-rw-r--r-- | app/func/remove_old_data.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/app/func/remove_old_data.py b/app/func/remove_old_data.py index 7380fc5..96d08fa 100644 --- a/app/func/remove_old_data.py +++ b/app/func/remove_old_data.py @@ -17,7 +17,8 @@ def remove_old_data(): link = row.link delete_links.append({'link': link}) - with engine.begin() as conn: - conn.execute(sqlalchemy.text('DELETE FROM links WHERE link = :link'), delete_links) - conn.execute(sqlalchemy.text('DELETE FROM records WHERE link = :link'), delete_links) - conn.commit() + if delete_links: + with engine.begin() as conn: + conn.execute(sqlalchemy.text('DELETE FROM links WHERE link = :link'), delete_links) + conn.execute(sqlalchemy.text('DELETE FROM records WHERE link = :link'), delete_links) + conn.commit() |