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