diff --git a/cache.py b/cache.py index 42a390d0..6e2ebdfc 100644 --- a/cache.py +++ b/cache.py @@ -804,14 +804,13 @@ def buildCache(tdenv, dbPath, sqlPath, pricesPath, importTables, defaultZero=Fal dbFilename = str(dbPath) # Create an in-memory database to populate with our data. tdenv.DEBUG0("Creating temporary database in memory") - tempDBName = dbFilename + ".new" - backupDBName = dbFilename + ".prev" - tempPath, backupPath = Path(tempDBName), Path(backupDBName) + tempPath = dbPath.with_suffix(".new") + backupPath = dbPath.with_suffix(".prev") if tempPath.exists(): tempPath.unlink() - tempDB = sqlite3.connect(tempDBName) + tempDB = sqlite3.connect(str(tempPath)) tempDB.execute("PRAGMA foreign_keys=ON") # Read the SQL script so we are ready to populate structure, etc. tdenv.DEBUG0("Executing SQL Script '{}' from '{}'", sqlPath, os.getcwd()) @@ -858,6 +857,8 @@ def importDataFromFile(tdb, tdenv, path, reset=False): existing records for that station in the database. """ + assert isinstance(path, Path) + if not path.exists(): raise TradeException("No such file: {}".format( str(path)