Skip to content

canal-python示例代码问题反馈 #41

@zhugw

Description

@zhugw

https://github.com/bithaolee/canal-python 最后的代码示例 问题修改反馈

  1. 只打印了最后一个字段 format_data每次都重新赋值而不是追加
format_data = dict()
if event_type == EntryProtocol_pb2.EventType.DELETE:
    for column in row.beforeColumns:
        format_data = {
            column.name: column.value
        }
elif event_type == EntryProtocol_pb2.EventType.INSERT:
    for column in row.afterColumns:
        format_data = {
            column.name: column.value
        }

==>

format_data = dict()
if event_type == EntryProtocol_pb2.EventType.DELETE:
    for column in row.beforeColumns:
        format_data[column.name] = column.value                    
elif event_type == EntryProtocol_pb2.EventType.INSERT:
    for column in row.afterColumns:
        format_data[column.name] = column.value
  1. before和after内容一样
format_data['before'] = format_data['after'] = dict()
==>
format_data['before'] = dict()
format_data['after'] = dict()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions