Guest User

Untitled

a guest
Nov 26th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. guid = str(uuid.uuid4())
  2. username = config.username
  3. dbpassword = config.dbpassword
  4. dbhost = config.dburl
  5. engine = create_engine('mysql://%s:%s@%s/db?charset=utf8' %(username, dbpassword, dbhost), encoding="utf-8")
  6. path = 'd:/anaconda3/lib/bin/'
  7. jsonFiles = os.listdir(path)
  8. maxSnapshotQuery = '''SELECT MAX(Snapshot) AS Snapshot FROM %s'''
  9.  
  10. for file in jsonFiles:
  11. tableName = file.split(".")[0]
  12. snapshotCheck = pd.read_sql_query(maxSnapshotQuery %tableName, engine)
  13. print(snapshotCheck['Snapshot'].dt.date)
  14. if snapshotCheck['Snapshot'].dt.date == datetime.datetime.now().date():
  15. with open(path+file) as f :
  16. try:
  17. rawJson = json.load(f)
  18. rawJson['authorizations'][0]['id'] = guid
  19. print(f.name + ' Load Completed')
  20. except ValueError as error:
  21. print(error + ' ' + f.name + ' Check the JSON within')
  22. continue
  23.  
  24.  
  25. createSession()
  26. createJob(session)
  27. loadData(data, engine)
Add Comment
Please, Sign In to add comment