aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2025-01-20 20:44:23 -0600
committerParker <contact@pkrm.dev>2025-01-20 20:44:23 -0600
commite5ede625b3fc7e0b71736b42eb4f52a2f5d63378 (patch)
tree5bc66919f871cdba0e8f6f9848aad1b0cdbed838 /code
parent4a1a69e76fae77f831648c5e126c5213edc4255d (diff)
Put database within data dir
Diffstat (limited to 'code')
-rw-r--r--code/cogs/newaccount.py2
-rw-r--r--code/cogs/status.py4
-rw-r--r--code/utils/config.py4
-rw-r--r--code/utils/content_view.py2
-rw-r--r--code/utils/jellyfin_create.py2
-rw-r--r--code/utils/jellyfin_delete.py2
6 files changed, 9 insertions, 7 deletions
diff --git a/code/cogs/newaccount.py b/code/cogs/newaccount.py
index b341147..54d53b6 100644
--- a/code/cogs/newaccount.py
+++ b/code/cogs/newaccount.py
@@ -20,7 +20,7 @@ class NewAccount(commands.Cog):
async def newaccount(self, interaction: discord.Interaction) -> None:
"""Create a new temporary Jellyfin account"""
# Make sure the user doesn't already have an account
- db = sqlite3.connect("cordarr.db")
+ db = sqlite3.connect("data/cordarr.db")
cursor = db.cursor()
cursor.execute(
"SELECT * FROM jellyfin_accounts WHERE user_id = ?",
diff --git a/code/cogs/status.py b/code/cogs/status.py
index abda84a..9e44bf6 100644
--- a/code/cogs/status.py
+++ b/code/cogs/status.py
@@ -19,7 +19,7 @@ class Status(commands.Cog):
@app_commands.command()
async def status(self, interaction: discord.Interaction) -> None:
"""Get the status of the movies you have requested"""
- db = sqlite3.connect("cordarr.db")
+ db = sqlite3.connect("data/cordarr.db")
cursor = db.cursor()
cursor.execute(
"SELECT title, release_year, local_id, tmdbid, tvdbid FROM"
@@ -183,7 +183,7 @@ class Status(commands.Cog):
# If the movie has a file, then it has finished downloading
if data.get("hasFile", True):
# Remove from database
- db = sqlite3.connect("cordarr.db")
+ db = sqlite3.connect("data/cordarr.db")
cursor = db.cursor()
cursor.execute(
"DELETE FROM requests WHERE user_id = ? AND"
diff --git a/code/utils/config.py b/code/utils/config.py
index f3fc971..9e1b687 100644
--- a/code/utils/config.py
+++ b/code/utils/config.py
@@ -153,7 +153,9 @@ def database_setup() -> None:
"""
Create the database if it does not exist
"""
- db = sqlite3.connect("cordarr.db")
+ if not os.path.exists("data"):
+ os.makedirs("data")
+ db = sqlite3.connect("data/cordarr.db")
cursor = db.cursor()
cursor.execute(
"CREATE TABLE IF NOT EXISTS requests (title TEXT, release_year TEXT,"
diff --git a/code/utils/content_view.py b/code/utils/content_view.py
index e8df29c..668954f 100644
--- a/code/utils/content_view.py
+++ b/code/utils/content_view.py
@@ -161,7 +161,7 @@ class RequestButtonView(discord.ui.View):
return await interaction.response.send_message(embed=embed)
# Keep track of the requests for the `/status` command
- db = sqlite3.connect("cordarr.db")
+ db = sqlite3.connect("data/cordarr.db")
cursor = db.cursor()
cursor.execute(
"INSERT INTO requests (title, release_year, local_id, tmdbid,"
diff --git a/code/utils/jellyfin_create.py b/code/utils/jellyfin_create.py
index 08c5230..e860c2b 100644
--- a/code/utils/jellyfin_create.py
+++ b/code/utils/jellyfin_create.py
@@ -67,7 +67,7 @@ def create_jellyfin_account(user_id):
return False
# Add the information to the database
- db = sqlite3.connect("cordarr.db")
+ db = sqlite3.connect("data/cordarr.db")
cursor = db.cursor()
cursor.execute(
"INSERT INTO jellyfin_accounts (user_id, jellyfin_user_id,"
diff --git a/code/utils/jellyfin_delete.py b/code/utils/jellyfin_delete.py
index 6164e40..66af00b 100644
--- a/code/utils/jellyfin_delete.py
+++ b/code/utils/jellyfin_delete.py
@@ -10,7 +10,7 @@ def delete_accounts():
Delete Jellyfin accounts that have passed their deletion time
"""
# Get all expired Jellyfin accounts
- db = sqlite3.connect("cordarr.db")
+ db = sqlite3.connect("data/cordarr.db")
cursor = db.cursor()
cursor.execute(
"SELECT jellyfin_user_id FROM jellyfin_accounts WHERE"