Put database within data dir
Some checks are pending
Create and publish a Docker image / build-and-push-image (push) Waiting to run

This commit is contained in:
Parker M. 2025-01-20 20:44:23 -06:00
parent 4a1a69e76f
commit e5ede625b3
Signed by: parker
GPG Key ID: 505ED36FC12B5D5E
6 changed files with 9 additions and 7 deletions

View File

@ -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 = ?",

View File

@ -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"

View File

@ -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,"

View File

@ -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,"

View File

@ -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,"

View File

@ -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"