db_updater.py
678 Bytes
from firebase_admin import db
from firebase_admin import credentials
import firebase_admin
from D_dayCalculator import D_day
import json
cred = credentials.Certificate('wello_firebase_SDKKey.json')
firebase_admin.initialize_app(cred, {'databaseURL': 'https://capstone-vip.firebaseio.com/'})
ref = db.reference()
policies = ref.get()
date = D_day("1970.01.01")
#with open('view_count_raw.json', 'rt', encoding='utf-8') as json_file:
# view_count = json.load(json_file)
for policy in policies:
# 날짜 갱신
date.update_date(policy["Date"])
print(date.date_calculate())
ref.child(policy["Value"]).child("D_day").set(date.date_calculate())