This repository has been archived on 2025-01-14. You can view files and clone it, but cannot push or open issues or pull requests.
messagearr/app/db_setup.py
Parker 237aec245e
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.
2024-03-22 22:09:55 -05:00

33 lines
838 B
Python

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()