Merge pull request #153 from aria1th/cmd-args-sqlite-db
add cmd-opts for sqlite file separationpull/127/head
commit
274aa6c82c
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
)
|
||||
Loading…
Reference in New Issue