|
1 | | -import struct |
2 | 1 | import logging |
3 | | -from packaging.version import Version |
| 2 | +import struct |
4 | 3 |
|
5 | 4 | import pymysql |
| 5 | +from packaging.version import Version |
6 | 6 | from pymysql.constants.COMMAND import COM_BINLOG_DUMP, COM_REGISTER_SLAVE |
7 | 7 | from pymysql.cursors import DictCursor |
8 | 8 |
|
9 | | -from .constants.BINLOG import TABLE_MAP_EVENT, ROTATE_EVENT, FORMAT_DESCRIPTION_EVENT |
| 9 | +from .constants.BINLOG import FORMAT_DESCRIPTION_EVENT, ROTATE_EVENT, TABLE_MAP_EVENT |
10 | 10 | from .event import ( |
11 | | - QueryEvent, |
12 | | - RotateEvent, |
13 | | - FormatDescriptionEvent, |
14 | | - XidEvent, |
15 | | - GtidEvent, |
16 | | - StopEvent, |
17 | | - XAPrepareEvent, |
18 | 11 | BeginLoadQueryEvent, |
19 | 12 | ExecuteLoadQueryEvent, |
| 13 | + FormatDescriptionEvent, |
| 14 | + GtidEvent, |
20 | 15 | HeartbeatLogEvent, |
21 | | - NotImplementedEvent, |
22 | | - MariadbGtidEvent, |
23 | 16 | MariadbAnnotateRowsEvent, |
24 | | - RandEvent, |
| 17 | + MariadbBinLogCheckPointEvent, |
| 18 | + MariadbGtidEvent, |
| 19 | + MariadbGtidListEvent, |
25 | 20 | MariadbStartEncryptionEvent, |
| 21 | + NotImplementedEvent, |
| 22 | + PreviousGtidsEvent, |
| 23 | + QueryEvent, |
| 24 | + RandEvent, |
| 25 | + RotateEvent, |
26 | 26 | RowsQueryLogEvent, |
27 | | - MariadbGtidListEvent, |
28 | | - MariadbBinLogCheckPointEvent, |
| 27 | + StopEvent, |
29 | 28 | UserVarEvent, |
30 | | - PreviousGtidsEvent, |
| 29 | + XAPrepareEvent, |
| 30 | + XidEvent, |
31 | 31 | ) |
32 | 32 | from .exceptions import BinLogNotEnabled |
33 | 33 | from .gtid import GtidSet |
34 | 34 | from .packet import BinLogPacketWrapper |
35 | 35 | from .row_event import ( |
36 | | - UpdateRowsEvent, |
37 | | - WriteRowsEvent, |
38 | 36 | DeleteRowsEvent, |
39 | | - TableMapEvent, |
40 | 37 | PartialUpdateRowsEvent, |
| 38 | + TableMapEvent, |
| 39 | + UpdateRowsEvent, |
| 40 | + WriteRowsEvent, |
41 | 41 | ) |
42 | 42 |
|
43 | 43 | try: |
@@ -185,6 +185,7 @@ def __init__( |
185 | 185 | slave_heartbeat=None, |
186 | 186 | is_mariadb=False, |
187 | 187 | annotate_rows_event=False, |
| 188 | + force_encoding=None, |
188 | 189 | ignore_decode_errors=False, |
189 | 190 | verify_checksum=False, |
190 | 191 | enable_logging=True, |
@@ -225,6 +226,8 @@ def __init__( |
225 | 226 | to point to Mariadb specific GTID. |
226 | 227 | annotate_rows_event: Parameter value to enable annotate rows event in mariadb, |
227 | 228 | used with 'is_mariadb' |
| 229 | + force_encoding: Force the encoding to decode a string this for MySQL 5.XXX This is the charset |
| 230 | + to use example latin-1 |
228 | 231 | ignore_decode_errors: If true, any decode errors encountered |
229 | 232 | when reading column data will be ignored. |
230 | 233 | verify_checksum: If true, verify events read from the binary log by examining checksums. |
@@ -252,6 +255,7 @@ def __init__( |
252 | 255 | only_events, ignored_events, filter_non_implemented_events |
253 | 256 | ) |
254 | 257 | self.__ignore_decode_errors = ignore_decode_errors |
| 258 | + self.__force_encoding = force_encoding |
255 | 259 | self.__verify_checksum = verify_checksum |
256 | 260 | self.__optional_meta_data = False |
257 | 261 |
|
@@ -628,6 +632,7 @@ def fetchone(self): |
628 | 632 | self.__ignored_schemas, |
629 | 633 | self.__freeze_schema, |
630 | 634 | self.__ignore_decode_errors, |
| 635 | + self.__force_encoding, |
631 | 636 | self.__verify_checksum, |
632 | 637 | self.__optional_meta_data, |
633 | 638 | ) |
|
0 commit comments