Merge pull request #153 from aria1th/cmd-args-sqlite-db

add cmd-opts for sqlite file separation
pull/127/head
ArtVenture 2023-10-23 02:59:49 +07:00 committed by GitHub
commit 274aa6c82c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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, "agent_scheduler_sqlite_file"):
# if relative path, join with basedir
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.agent_scheduler_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(
"--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",
)