consolidator
/
downloadCode.py
22 строки · 869.0 Байт
1import sqlalchemy as sa2import json3from MyConfig import MyConfig4
5if __name__=="__main__":6try:7mysql_prod= "mariadb+pymysql://uupadmin:uupadmin@vsys01775:3306"8engine = sa.create_engine(mysql_prod)9sql = sa.text("SELECT name, code FROM consolidation.handlers")10cfg = MyConfig("consolidation.json")11hdict:dict = cfg.get("level2 handlers",None)12with engine.connect() as conn:13for rec in conn.execute(sql):14rdict = rec._asdict()15with open(f"handlers2\\{hdict[rdict['name']]}.py",mode="w",encoding="utf-8") as f:16f.write(rdict["code"])17f.flush()18f.close()19print(f"{rdict['name']} : {hdict[rdict['name']]} - done")20conn.close()21except Exception as exp:22print(f"error: {exp}")23