add cmd-opts for sqlite file separation

pull/153/head
aria1th 2023-10-20 00:35:38 +09:00
parent 1d623c62fd
commit 74a8dc88be
2 changed files with 17 additions and 3 deletions

View File

@ -5,14 +5,21 @@ from sqlalchemy.schema import MetaData
from sqlalchemy.orm import declarative_base
from modules import scripts
from modules import shared
if hasattr(shared.cmd_opts, "sqlite_file"):
# if relative path, join with basedir
if not os.path.isabs(shared.cmd_opts.sqlite_file):
db_file = os.path.join(scripts.basedir(), shared.cmd_opts.sqlite_file)
else:
db_file = os.path.abspath(shared.cmd_opts.sqlite_file)
print(f"Using sqlite file: {db_file}")
Base = declarative_base()
metadata: MetaData = Base.metadata
db_file = os.path.join(scripts.basedir(), "task_scheduler.sqlite3")
class BaseTableManager:
def __init__(self, engine = None):
# Get the db connection object, making the file and tables if needed.

7
preload.py Normal file
View File

@ -0,0 +1,7 @@
# preload.py is used for cmd line arguments
def preload(parser):
parser.add_argument(
"--sqlite-file",
help="sqlite file to use for the database connection. It can be abs or relative path(from base path) default: task_scheduler.sqlite3",
default="task_scheduler.sqlite3",
)