Jeremy White : Make the database location configurable.

Alexandre Julliard julliard at winehq.org
Wed Apr 27 14:34:47 CDT 2022


Module: tools
Branch: master
Commit: 195e2f6d6f18e63b7bef4f2f9bbf88a21bf0d855
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=195e2f6d6f18e63b7bef4f2f9bbf88a21bf0d855

Author: Jeremy White <jwhite at codeweavers.com>
Date:   Tue Apr 26 13:29:02 2022 -0500

Make the database location configurable.

Rather than being implicity based on argv[1]

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 gitlab/gitlab-to-mail/db.py               | 7 ++++++-
 gitlab/gitlab-to-mail/settings_example.py | 3 +++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/gitlab/gitlab-to-mail/db.py b/gitlab/gitlab-to-mail/db.py
index 118d3c7..472026c 100644
--- a/gitlab/gitlab-to-mail/db.py
+++ b/gitlab/gitlab-to-mail/db.py
@@ -1,8 +1,13 @@
 from sqlalchemy import create_engine, Column, Integer, Unicode, DateTime, Date
 from sqlalchemy.orm import declarative_base, sessionmaker
 
+import importlib
+import os
 import sys
 
+sys.path.append(os.getcwd())
+settings = importlib.import_module(f"settings_{sys.argv[1]}")
+
 Base = declarative_base()
 
 
@@ -25,7 +30,7 @@ class GlobalState(Base):
     integer_value = Column(Integer)
 
 
-engine = create_engine(f"sqlite:///db_{sys.argv[1]}.sqlite", echo=False)
+engine = create_engine(f"sqlite:///{settings.DATABASE}", echo=False)
 Base.metadata.create_all(engine)
 Session = sessionmaker(bind=engine)
 session = Session()
diff --git a/gitlab/gitlab-to-mail/settings_example.py b/gitlab/gitlab-to-mail/settings_example.py
index fca80a2..1a42216 100644
--- a/gitlab/gitlab-to-mail/settings_example.py
+++ b/gitlab/gitlab-to-mail/settings_example.py
@@ -1,3 +1,6 @@
+# Location of the sqlite database file, which will be auto created if not found
+DATABASE= "/home/wine/example/db_example.sqlite"
+
 # if True mails are dumped to mail_dump mbox file instead of being sent out
 DEBUG = False
 




More information about the wine-cvs mailing list