Skip to content

from MrWind #10

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ python >= 3

````shell
pip install canal-python
pip install protobuf
````

### 建立与Canal的连接
Expand Down Expand Up @@ -125,5 +126,5 @@ while True:
client.disconnect()
````

更多详情请查看 [Sample](https://github.com/haozi3156666/canal-python/blob/master/example.py)
更多详情请查看 [Sample](https://github.com/haozi3156666/canal-python/blob/master/canal/example.py)

11 changes: 4 additions & 7 deletions canal/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,13 @@ def rollback(self, batch_id):
format_data = dict()
if event_type == EntryProtocol_pb2.EventType.DELETE:
for column in row.beforeColumns:
format_data = {
column.name: column.value
}
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[column.name] = column.value
else:
format_data['before'] = format_data['after'] = dict()
format_data['before'] = dict()
format_data['after'] = dict()
for column in row.beforeColumns:
format_data['before'][column.name] = column.value
for column in row.afterColumns:
Expand Down
11 changes: 4 additions & 7 deletions canal/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@
format_data = dict()
if event_type == EntryProtocol_pb2.EventType.DELETE:
for column in row.beforeColumns:
format_data = {
column.name: column.value
}
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[column.name] = column.value
else:
format_data['before'] = format_data['after'] = dict()
format_data['before'] = dict()
format_data['after'] = dict()
for column in row.beforeColumns:
format_data['before'][column.name] = column.value
for column in row.afterColumns:
Expand Down