code_transform.py 766 B

1234567891011121314151617181920212223
  1. from sqlalchemy import create_engine
  2. from sqlalchemy.orm import sessionmaker
  3. from urllib import parse
  4. import pymysql
  5. import pandas as pd
  6. # 数据库配置
  7. host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
  8. port=3306
  9. database='algo_dict'
  10. user='qx_algo_readonly'
  11. password='qx@123456'
  12. db_engine = create_engine(
  13. "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
  14. user, password, host, port, database
  15. ))
  16. DbSession = sessionmaker(bind=db_engine)
  17. errorcode_map = pd.read_sql("select * from faultcode_map", db_engine)
  18. p=1 # 协议 1:科易,2: 优旦/格林美, 3:自研'
  19. code = 1 # 终端故障码
  20. platform_code = errorcode_map[(errorcode_map['protocol']==p)&(errorcode_map['end_errorcode']==str(p))]['platform_errorcode']
  21. db_engine.dispose()