当前位置: 首页>>代码示例>>Python>>正文


Python BinLogStreamReader.__sizeof__方法代码示例

本文整理汇总了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()
开发者ID:kawadhiya21,项目名称:mysql-event-pub-sub,代码行数:33,代码来源:server.py


注:本文中的pymysqlreplication.BinLogStreamReader.__sizeof__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。