add cmd-opts for sqlite file separation
parent
1d623c62fd
commit
74a8dc88be
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
)
|
||||
Loading…
Reference in New Issue