有没有办法使用sql炼金术来获得当前的奴隶滞后? session.execute('show slave status')似乎不返回任何行:
In [0]: list(session.execute('show slave status'))
ResourceClosedError: This result object does not return rows. It has been closed automatically.
答案 0 :(得分:2)
from sqlalchemy import create_engine
engine = create_engine('mysql+pymysql://username:password@your.hostname.com/')
connection = engine.connect()
result = connection.execute("SHOW SLAVE STATUS")
for row in result:
for k in row.keys():
print k, ' >>> ', row[k]