From 237aec245e2a135b848dfd3c8dcf46cb755f08e9 Mon Sep 17 00:00:00 2001 From: Parker Date: Fri, 22 Mar 2024 22:09:55 -0500 Subject: Large Overhaul - Jellyfin Temp Accounts Temporary jellyfin accounts can now be made through messaging. Commands were moved out and into their own files and functions for organization. --- app/db_setup.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app/db_setup.py (limited to 'app/db_setup.py') diff --git a/app/db_setup.py b/app/db_setup.py new file mode 100644 index 0000000..702449b --- /dev/null +++ b/app/db_setup.py @@ -0,0 +1,32 @@ +import os +import sqlite3 +import initialize_variables + +""" +This function is run before the application starts - creates database and sets connection string +""" +def setup_db(): + IN_DOCKER = os.environ.get('IN_DOCKER', False) + if IN_DOCKER: + db = sqlite3.connect('/data/movies.db') + initialize_variables.db_path = '/data/movies.db' + else: + db = sqlite3.connect('movies.db') + initialize_variables.db_path = 'movies.db' + + cursor = db.cursor() + cursor.execute(''' + CREATE TABLE IF NOT EXISTS movies( + from_number TEXT, + movie_id TEXT, + movie_title TEXT + ) + ''') + cursor.execute(''' + CREATE TABLE IF NOT EXISTS jellyfin_accounts( + user_id TEXT, + deletion_time DATETIME + ) + ''') + db.commit() + db.close() -- cgit v1.2.3-70-g09d2