diff options
author | Parker <contact@pkrm.dev> | 2025-01-21 20:38:33 -0600 |
---|---|---|
committer | Parker <contact@pkrm.dev> | 2025-01-21 20:38:33 -0600 |
commit | b0ea7ab93564f1b2f004f7ea74783508f12f4ff6 (patch) | |
tree | 2bf229bff30649598bd651d15fcf1ec9feaf4b13 /code/utils/content_view.py | |
parent | 023ee141ebf437919a4c0f43ddee18aaefa4cbbc (diff) |
Fixes + Use SQLAlchemy
Diffstat (limited to 'code/utils/content_view.py')
-rw-r--r-- | code/utils/content_view.py | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/code/utils/content_view.py b/code/utils/content_view.py index 7a982c0..4f5673e 100644 --- a/code/utils/content_view.py +++ b/code/utils/content_view.py @@ -1,6 +1,7 @@ import discord -import sqlite3 +from utils.models import Requests +from utils.database import Session from utils.content_add import add_content """ @@ -163,30 +164,26 @@ class RequestButtonView(discord.ui.View): ) # Keep track of the requests for the `/status` command - db = sqlite3.connect("data/cordarr.db") - cursor = db.cursor() - cursor.execute( - "INSERT INTO requests (title, release_year, local_id, tmdbid," - " tvdbid, user_id) VALUES (?, ?, ?, ?, ?, ?)", - ( - self.content_info["title"], - self.content_info["year"], - local_id, - ( - self.content_info["contentId"] - if self.service == "radarr" - else None - ), - ( - None - if self.service == "radarr" - else self.content_info["contentId"] - ), - interaction.user.id, - ), - ) - db.commit() - db.close() + with Session() as session: + session.add( + Requests( + title=self.content_info["title"], + release_year=self.content_info["year"], + local_id=local_id, + tmdbid=( + self.content_info["contentId"] + if self.service == "radarr" + else None + ), + tvdbid=( + None + if self.service == "radarr" + else self.content_info["contentId"] + ), + user_id=interaction.user.id, + ) + ) + session.commit() @discord.ui.button(label="Don't Request", style=discord.ButtonStyle.danger) async def dont_request_button( |