Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zhugw opened this issue Mar 30, 2023 · 0 comments
Open

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

zhugw opened this issue Mar 30, 2023 · 0 comments

Comments

@zhugw
Copy link

zhugw commented Mar 30, 2023

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant