aboutsummaryrefslogtreecommitdiff
path: root/app/db_setup.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/db_setup.py')
-rw-r--r--app/db_setup.py32
1 files changed, 32 insertions, 0 deletions
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()