diff --git a/trade.py b/trade.py index 5623768a..199efad0 100644 --- a/trade.py +++ b/trade.py @@ -556,7 +556,10 @@ def main(): print("For help on a specific command, type: %s {command} -h" % (parser.prog)) sys.exit(1) + # load the database tdb = TradeDB(debug=args.debug, dbFilename=args.db) + + # run the commands return args.proc(args) diff --git a/tradedb.py b/tradedb.py index 4658c455..32b1a1ad 100644 --- a/tradedb.py +++ b/tradedb.py @@ -278,10 +278,12 @@ def _connectToDB(self): # Make sure we don't hold on to an existing connection. if self.conn: + if self.debug > 2: print("x Disconnect DB") self.conn.close() self.conn = None try: + if self.debug > 1: print("* Connecting to DB") import sqlite3 self.dbModule = sqlite3 self.conn = self.dbModule.connect(self.dbURI) @@ -323,7 +325,7 @@ def reloadCache(self): if dbFileCreatedTimestamp > max(sqlFileTimestamp, pricesFileTimestamp): # db is newer. if self.debug > 1: - print("reloadCache: db file is newer. db:{} > max(sql:{}, prices:{}".format(dbFileCreatedTimestamp, sqlFileTimestamp, pricesFileTimestamp)) + print("- SQLite is up to date") return if self.debug: @@ -585,6 +587,8 @@ def load(self, dbFilename=None): tdb.load() # x now points to an orphan Aulin """ + if self.debug > 1: print("* Loading data") + self.cur = self.conn.cursor() # Load raw tables. Stations will be linked to systems, but nothing else.