Files
new_dbsync/db/mssql/Updater.py
T
2025-05-20 12:02:07 -04:00

40 lines
1.1 KiB
Python

import sqlalchemy
import progressbar
from tvmaze.Processor import loadjson
class Updater():
def __init__(self):
global jprocess
def __del__(self):
pass
class tvupdates():
def __init__(self):
pass
def update_tables(engine, updatesapi, tablename):
jprocess = loadjson()
print('Now retrieving available updates.')
print('Creating update transaction.')
ins = tablename.insert()
seriesupdates = jprocess.load(updatesapi)
updatelist = []
seriesrange = len(seriesupdates)
with progressbar.ProgressBar(maxval=seriesrange, redirect_stdout=True) as p:
for key, value in seriesupdates.items():
i = int(key)
updater = {}
updater['seriesid'] = key
updater['timestamp'] = value
updatelist.append(updater)
if i <= seriesrange:
p.update(i)
#time.sleep(0.1)
print('Update of tvupdates table is complete.')
print('Done.')
return(ins, updatelist)
def __del__(self):
pass