Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow loan history DB name to be configured #588

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions default.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ hideCoins = True

#[ACCOUNTSTATS]
#ReportInterval = 86400
#DatabaseName = loan_history

#[CHARTS]
#DumpInterval = 21600
Expand Down
4 changes: 4 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion plugins/AccountStats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "DatabaseName", "loan_history")

def before_lending(self):
for coin in self.earnings:
Expand All @@ -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()

Expand Down