本文整理汇总了Python中pymysqlreplication.BinLogStreamReader.__sizeof__方法的典型用法代码示例。如果您正苦于以下问题:Python BinLogStreamReader.__sizeof__方法的具体用法?Python BinLogStreamReader.__sizeof__怎么用?Python BinLogStreamReader.__sizeof__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymysqlreplication.BinLogStreamReader
的用法示例。
在下文中一共展示了BinLogStreamReader.__sizeof__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BinLogStreamReader
# 需要导入模块: from pymysqlreplication import BinLogStreamReader [as 别名]
# 或者: from pymysqlreplication.BinLogStreamReader import __sizeof__ [as 别名]
import util as UTIL
import config as CONFIG
# Fetch the latest log_pos
log_pos = UTIL.fetch_latest_log_pos()
# Initialize ZMQ to publish
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:%s" % CONFIG.ZMQ_PORT)
print "Publishing starts !!!!! -----------------------------"
while True:
# Create a stream of the mysqlbinlog
stream = BinLogStreamReader(connection_settings = CONFIG.CONNECTION_SETTINGS, server_id = CONFIG.SERVER_ID, only_events = CONFIG.EVENTS, log_pos = log_pos)
latest_log_pos = log_pos
print "Publishing stream of length " + str(stream.__sizeof__())
for event in stream:
data = dict()
# Collect data
data['event'] = event.__class__.__name__
data['table'] = event.table
data['rows'] = UTIL.stringalise(event.rows)
data['timestamp'] = str(event.timestamp)
# Publish !
socket.send(json.dumps(data))
latest_log_pos = event.packet.log_pos
if latest_log_pos == log_pos:
print "Nothing to publish!"
log_pos = latest_log_pos
sleep(CONFIG.REFRESH_TIME)
stream.close()