diff options
author | Parker <contact@pkrm.dev> | 2024-06-24 16:24:09 -0500 |
---|---|---|
committer | Parker <contact@pkrm.dev> | 2024-06-24 16:24:09 -0500 |
commit | 5b92454760a8af14bd1031e72024946f868d1de6 (patch) | |
tree | f8384cbf0d142777d9bff341e13fd5882182908b /app/func/remove_old_data.py | |
parent | 80a39d38bf829193c655a7320c86df2a3146db2a (diff) |
Major overhaul + Bare bones web UI
Diffstat (limited to 'app/func/remove_old_data.py')
-rw-r--r-- | app/func/remove_old_data.py | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/app/func/remove_old_data.py b/app/func/remove_old_data.py deleted file mode 100644 index 96d08fa..0000000 --- a/app/func/remove_old_data.py +++ /dev/null @@ -1,24 +0,0 @@ -import sqlalchemy -import datetime - -from db import engine - -""" -Remove all links and associated records when the expire date has passed -""" -def remove_old_data(): - with engine.begin() as conn: - today = datetime.datetime.date(datetime.datetime.now()) - old_links = conn.execute(sqlalchemy.text('SELECT link FROM links WHERE expire_date < :today'), [{'today': today}]) - - delete_links = [] - - for row in old_links: - link = row.link - delete_links.append({'link': link}) - - 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() |