From 74a8dc88bed114ed44196ec80c1b8a4087d41265 Mon Sep 17 00:00:00 2001 From: aria1th <35677394+aria1th@users.noreply.github.com> Date: Fri, 20 Oct 2023 00:35:38 +0900 Subject: [PATCH 1/2] add cmd-opts for sqlite file separation --- agent_scheduler/db/base.py | 13 ++++++++++--- preload.py | 7 +++++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 preload.py diff --git a/agent_scheduler/db/base.py b/agent_scheduler/db/base.py index 285d4af..0ae2210 100644 --- a/agent_scheduler/db/base.py +++ b/agent_scheduler/db/base.py @@ -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. diff --git a/preload.py b/preload.py new file mode 100644 index 0000000..c805389 --- /dev/null +++ b/preload.py @@ -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", + ) \ No newline at end of file From 7be6f47849507828300e41bdbc92ac26a45449b7 Mon Sep 17 00:00:00 2001 From: aria1th <35677394+aria1th@users.noreply.github.com> Date: Fri, 20 Oct 2023 19:07:14 +0900 Subject: [PATCH 2/2] fix command arg name for sqlite database --- agent_scheduler/db/base.py | 8 ++++---- preload.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/agent_scheduler/db/base.py b/agent_scheduler/db/base.py index 0ae2210..abad8a6 100644 --- a/agent_scheduler/db/base.py +++ b/agent_scheduler/db/base.py @@ -7,12 +7,12 @@ from sqlalchemy.orm import declarative_base from modules import scripts from modules import shared -if hasattr(shared.cmd_opts, "sqlite_file"): +if hasattr(shared.cmd_opts, "agent_scheduler_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) + if not os.path.isabs(shared.cmd_opts.agent_scheduler_sqlite_file): + db_file = os.path.join(scripts.basedir(), shared.cmd_opts.agent_scheduler_sqlite_file) else: - db_file = os.path.abspath(shared.cmd_opts.sqlite_file) + db_file = os.path.abspath(shared.cmd_opts.agent_scheduler_sqlite_file) print(f"Using sqlite file: {db_file}") diff --git a/preload.py b/preload.py index c805389..8dc3f85 100644 --- a/preload.py +++ b/preload.py @@ -1,7 +1,7 @@ # preload.py is used for cmd line arguments def preload(parser): parser.add_argument( - "--sqlite-file", + "--agent-scheduler-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", ) \ No newline at end of file