0

有没有办法使用 sql alchemy 获得当前的奴隶滞后?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.
4

1 回答 1

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]
于 2013-01-19T01:59:45.600 回答