Add DB_SQLITE3_PATH config option

Rather than being hardcoded

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2023-08-02 18:40:45 -07:00
parent af3a8b9a1e
commit af3e14a7aa
3 changed files with 8 additions and 4 deletions

View File

@@ -26,5 +26,7 @@ def default(name: str, default: str) -> str:
THUMBS_DIR = Path(default("THUMBS_DIR", "thumbs")) THUMBS_DIR = Path(default("THUMBS_DIR", "thumbs"))
CACHE_DIR = Path(default("CACHE_DIR", "cache")) CACHE_DIR = Path(default("CACHE_DIR", "cache"))
DB_SQLITE3_PATH = Path(default("DB_SQLITE3_PATH", "bans.db"))
HTTP_DOMAIN = required("HTTP_DOMAIN") HTTP_DOMAIN = required("HTTP_DOMAIN")
HTTP_ROOT = default("HTTP_ROOT", r"/") HTTP_ROOT = default("HTTP_ROOT", r"/")

View File

@@ -2,12 +2,11 @@ import sqlite3
import sys import sys
from typing import Optional from typing import Optional
from . import config
DB_PATH = "bans.db"
def get_db(db_path: str = DB_PATH): def get_db():
db = sqlite3.connect(db_path) db = sqlite3.connect(config.DB_SQLITE3_PATH)
# ensure that the database exists # ensure that the database exists
db.executescript( db.executescript(
""" """

View File

@@ -4,6 +4,9 @@
# HTML cache directory. Defaults to "cache" # HTML cache directory. Defaults to "cache"
#CACHE_DIR=cache #CACHE_DIR=cache
# Sqlite3 database path. Defaults to "bans.db"
#DB_SQLITE3_PATH=bans.db
# Domain name of the server # Domain name of the server
HTTP_DOMAIN=domain.com HTTP_DOMAIN=domain.com