from sqlalchemy import * from sqlalchemy.orm import Session from sqlalchemy.ext.automap import automap_base from sqlalchemy.orm.session import make_transient from sqlalchemy.orm import load_only
connect_string = "mssql+pymssql://user:pass@url:3433/dbname?charset=utf8" # sqlserver
# mysql engine = create_engine('mysql+pymysql://root:111@10.254.20.185/monitor?charset=utf8', echo=False) metadata_r = MetaData() metadata_r.reflect(engine, only=['comp_info']) Base_r = automap_base(metadata=metadata_r) Base_r.prepare() comp_info = Base_r.classes.comp_info session = Session(engine) res = session.query(comp_info).filter(comp_info.flag == message).all()