diff --git a/db/sql.py b/db/sql.py index e075903..82cd2ae 100644 --- a/db/sql.py +++ b/db/sql.py @@ -25,12 +25,12 @@ class Dbexec(): ] # Commented out code for applying updates for now. Will re-enable later after downloads are verified. - # print('Applying updates to table.') - # with engine.connect() as conn: + print('Applying updates to table.') + with engine.connect() as conn: # conn.execute(text(f"truncate table {tablename}")) # conn.execute(tablename.insert(), updatelist) - # conn.commit() - # print('Update of tvupdates table is complete.') + conn.commit() + print('Update of tvupdates table is complete.') def rawsql_select(self, engine, sqlquery, lprint): session = Session(engine) diff --git a/json_downloader.py b/json_downloader.py index c73e819..e3eaa12 100644 --- a/json_downloader.py +++ b/json_downloader.py @@ -16,7 +16,7 @@ def download_json_to_file(api_url, outputdir, output_file, lprint): with open(f"{outputdir}{output_file}", 'w') as f: json.dump(data, f, indent=4) #print(f"JSON data saved to {outputdir}{output_file}") - time.sleep(.5) # Sleep for 0.5 second to avoid overwhelming the server + time.sleep(0.5) # Sleep for 0.5 second to avoid overwhelming the server except Exception as e: lprint.logprint("info", f"Downloadinng {outputdir}{output_file} for series ID: {output_file.replace('.json', '')} failed: {e}") diff --git a/settings/tvsync_settings.cfg b/settings/tvsync_settings.cfg index fb15e3a..abd8dc7 100644 --- a/settings/tvsync_settings.cfg +++ b/settings/tvsync_settings.cfg @@ -1,5 +1,5 @@ [global] -loglevel=debug +loglevel=info [dbsettings] sqlserver_driver=ODBC Driver 13 for SQL Server diff --git a/update_mongo.py b/update_mongo.py index e6bebfd..80281b5 100755 --- a/update_mongo.py +++ b/update_mongo.py @@ -199,7 +199,7 @@ def main() -> int: # TVMAZE_URLS is a dict of urls; use the updatesurl if available updates_url = TVMAZE_URLS.get('updatesurl') if isinstance(TVMAZE_URLS, dict) else None if updates_url: - json_downloader.download_json_to_file(updates_url, tempdir, out_file) + json_downloader.download_json_to_file(updates_url, tempdir, out_file, lprint) # load and convert saved JSON into a dict (id -> timestamp) try: downloaded_updates_dict = {} @@ -257,8 +257,8 @@ def main() -> int: downloaded_updates_list = [] except Exception: # non-fatal; continue - pass - del downloaded_updates_list + lprint.logprint("warning", "Failed to save or load downloaded updates JSON.") + #del downloaded_updates_list previouslisting = dbExec.rawsql_select( dbengine["engine"], "select seriesid, timestamp from updates.tvupdates order by seriesid",