From e51b6ade9a690935e754867c33bf6d58d83de202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phillip=20K=C3=BChne?= Date: Fri, 31 May 2019 03:52:37 +0200 Subject: [PATCH] Move database and config to /data --- app/database.py | 2 +- app/helpers.py | 8 +++++++- app/main.py | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/database.py b/app/database.py index 8c73a0a..3e7ecf5 100644 --- a/app/database.py +++ b/app/database.py @@ -9,7 +9,7 @@ entry_table = "entries" index_label = "Id" def open_db(): - conn = sqlite3.connect("test.db") + conn = sqlite3.connect("data/test.db") conn.execute('PRAGMA encoding = "UTF-8";') return conn diff --git a/app/helpers.py b/app/helpers.py index d2a5e63..5ac2a0d 100644 --- a/app/helpers.py +++ b/app/helpers.py @@ -3,7 +3,13 @@ from bs4 import BeautifulSoup import json import os -config_file = "config.json" +data_directory = "data" +config_file = data_directory+"/config.json" + +def create_data_directory(): + if not os.path.exists(data_directory): + os.makedirs(data_directory) + def get_catalog_url(): r = requests.get('https://www.karafun.de/karaoke-song-list.html') diff --git a/app/main.py b/app/main.py index 98d81ac..744a653 100644 --- a/app/main.py +++ b/app/main.py @@ -78,6 +78,7 @@ def admin(): @app.before_first_request def activate_job(): + helpers.create_data_directory() database.create_entry_table() database.create_song_table() database.create_list_view()