get_dic.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import datetime
  2. from unitls.LogerinTxt import app_logger
  3. from .flightDB import flightDB
  4. def get_dic(database:flightDB, data):
  5. try:
  6. fdb = database
  7. IDS=fdb.getSingledata("工号",'workerinfo')
  8. IDSNOW=[]
  9. try:
  10. for myrow in data:
  11. mydics0 = myrow["0"]
  12. mydics1 = myrow["1"]
  13. #a= fdb.getSingledata("工号",'workerinfo')
  14. if str(mydics0["工号"]) in str(IDS) or str(mydics0["工号"]) in IDSNOW:
  15. fdb.lazyUpdateItem('workerinfo',mydics1,"工号='%s'"%mydics0["工号"])
  16. else:
  17. fdb.lazyInsertData('workerinfo',mydics0)
  18. IDSNOW.append(mydics0["工号"])
  19. #print(1)
  20. fdb.FunctionCommit()
  21. return "ok"
  22. except Exception as e:
  23. print(datetime.datetime.now(),'[数据库操作]数据库获取错误!!检查通讯录文件!人员显示功能失效!!')
  24. print(e)
  25. app_logger.log_error(e)
  26. # 需要QT输出警告弹框信息
  27. fdb.FunctionCommit()
  28. return "fail"
  29. except Exception as e:
  30. app_logger.log_error(e)
  31. return "fail"