Issue with AccountStats db initialization
Hello, I may be wrong about this, but it would appear that when the sqlite database is empty, AccountStats can't update correctly. I believe the issue is in AccountStats.py in the line 56:
if (self.get_db_version() == 0) and (self.get_first_timestamp() is not None):
If i'm not correct, the db_version is set to 0 when there's nothing in the database, but self.get_first_timestamp() will always return None if there is nothing in the database. I think this means that this if statement is never executed.
If this isn't correct, is there a standard way to initialize the database that I missed?
Hi, Thanks for reviewing the code.
In line 53 there is a call to fetch history the first time would be from BITCOIN_GENESIS_BLOCK_DATE (which also stores it in the DB). So if the call in line 53 worked and history was retrieved, self.get_first_timestamp() will not be None.
The logic of the if on line 56 is that if you don't have history so far there isn't a point to loop back and try and fetch the rest of the history.
Is there a reason why you are asking? is something not working as expected?
I'm getting a constantly getting this message: self.log.log_error('AccountStats DB isn't ready.')
when I start. It repeats on the regular 5m period.
Well the DB tried to update it self every 5m, if it fails constantly for some reason you'll see that message.
Do you see other errors?
No unfortunately not. Other than having sqlite3, and the python libraries for it, should there be anything else I need to do to get the DB working?
Not really, you can try deleting the sqlite3 file and restarting the bot.
Actually, have you tested it with no loan history? On my account I just started loans and none have finished yet. What happens if the loan history is empty when it tries to fetch? I think get no results and nothing gets put in the database, right?
yeah... that makes sense now. :) Then you'll stop getting those errors ones one loan will be finished. Could improve on that maybe... there is no logic problem here.
We should add a catch for this, or at least add a message explaining this could be the case.