From fc2ac83cd6be1086cc3d0160b192180884fae98f Mon Sep 17 00:00:00 2001 From: Michael Robinson Date: Tue, 5 Dec 2017 07:59:06 +0000 Subject: [PATCH 1/2] Allow loan history DB name to be configured --- default.cfg.example | 1 + plugins/AccountStats.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/default.cfg.example b/default.cfg.example index 478576bc..f124f843 100644 --- a/default.cfg.example +++ b/default.cfg.example @@ -130,6 +130,7 @@ hideCoins = True #[ACCOUNTSTATS] #ReportInterval = 86400 +#database_name = loan_history #[CHARTS] #DumpInterval = 21600 diff --git a/plugins/AccountStats.py b/plugins/AccountStats.py index 3a611ad7..d78e3b87 100644 --- a/plugins/AccountStats.py +++ b/plugins/AccountStats.py @@ -33,6 +33,7 @@ def on_bot_init(self): self.init_db() self.check_upgrade() self.report_interval = int(self.config.get("ACCOUNTSTATS", "ReportInterval", 86400)) + self.database_name = self.config.get("ACCOUNTSTATS", "database_name", "loan_history") def before_lending(self): for coin in self.earnings: @@ -49,7 +50,7 @@ def after_lending(self): # noinspection PyAttributeOutsideInit def init_db(self): - self.db = sqlite3.connect('market_data/loan_history.sqlite3') + self.db = sqlite3.connect('market_data/{0}.sqlite3'.format(self.database_name)) self.db.execute(DB_CREATE) self.db.commit() From a314520b4e70d5ceb63a29d0cc867c6e62fc6573 Mon Sep 17 00:00:00 2001 From: Michael Robinson Date: Tue, 5 Dec 2017 08:23:17 +0000 Subject: [PATCH 2/2] Update docs and align option name with the other options --- default.cfg.example | 2 +- docs/configuration.rst | 4 ++++ plugins/AccountStats.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/default.cfg.example b/default.cfg.example index f124f843..441236cb 100644 --- a/default.cfg.example +++ b/default.cfg.example @@ -130,7 +130,7 @@ hideCoins = True #[ACCOUNTSTATS] #ReportInterval = 86400 -#database_name = loan_history +#DatabaseName = loan_history #[CHARTS] #DumpInterval = 21600 diff --git a/docs/configuration.rst b/docs/configuration.rst index 2ead85fa..16912930 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -384,6 +384,10 @@ There is an optional setting to change how frequently this plugin reports. By de [ACCOUNTSTATS] ReportInterval = 1800 +The name of the database file can also be configured in the same section:: + + DatabaseName = loan_history + Be aware that first initialization might take longer as the bot will fetch all the history. Profit Charts Plugin diff --git a/plugins/AccountStats.py b/plugins/AccountStats.py index d78e3b87..a5f53461 100644 --- a/plugins/AccountStats.py +++ b/plugins/AccountStats.py @@ -33,7 +33,7 @@ def on_bot_init(self): self.init_db() self.check_upgrade() self.report_interval = int(self.config.get("ACCOUNTSTATS", "ReportInterval", 86400)) - self.database_name = self.config.get("ACCOUNTSTATS", "database_name", "loan_history") + self.database_name = self.config.get("ACCOUNTSTATS", "DatabaseName", "loan_history") def before_lending(self): for coin in self.earnings: