Skip to content

Commit 729d8d3

Browse files
committed
fixed : commit conflict
2 parents d521385 + 62a009c commit 729d8d3

16 files changed

+463
-92
lines changed

.github/workflows/pytest.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ jobs:
2828
run: |
2929
docker compose create
3030
docker compose start
31-
# Wait for the services to accept connections,
32-
# TODO: do that smarter, poll connection attempt until it succeeds
33-
sleep 30
31+
echo "wait mysql server"
32+
33+
while :
34+
do
35+
if mysql -h 127.0.0.1 --user=root --execute "SELECT version();" 2>&1 >/dev/null && mysql -h 127.0.0.1 --port=3307 --user=root --execute "SELECT version();" 2>&1 >/dev/null; then
36+
break
37+
fi
38+
sleep 1
39+
done
40+
41+
echo "run pytest"
3442
3543
- name: Install dependencies
3644
run: |

.mariadb/my.cnf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[client-server]
2+
# Port or socket location where to connect
3+
# port = 3306
4+
socket = /run/mysqld/mysqld.sock
5+
6+
# Import all .cnf files from configuration directory
7+
8+
!includedir /etc/mysql/mariadb.conf.d/
9+
!includedir /etc/mysql/conf.d/
10+
11+
12+
[mariadb]
13+
plugin_load_add = file_key_management
14+
# Key files that are not encrypted
15+
loose_file_key_management_filename = /opt/key_file/no_encryption_key.key
16+
17+
# Encrypted key file
18+
# loose_file_key_management_filename=/opt/key_file/keyfile.enc
19+
# loose_file_key_management_filekey=FILE:/opt/key_file/no_encryption_key.key
20+
# file_key_management_encryption_algorithm=aes_ctr
21+
22+
# Set encrypt_binlog
23+
encrypt_binlog=ON

.mariadb/no_encryption_key.key

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1;dda0ccb18a28b0b4c2448b5f0217a134

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ python-mysql-replication
44
<a href="https://travis-ci.org/noplay/python-mysql-replication"><img src="https://travis-ci.org/noplay/python-mysql-replication.svg?branch=master"></a>&nbsp;
55
<a href="https://pypi.python.org/pypi/mysql-replication"><img src="http://img.shields.io/pypi/dm/mysql-replication.svg"></a>
66

7-
Pure Python Implementation of MySQL replication protocol build on top of PyMYSQL. This allow you to receive event like insert, update, delete with their datas and raw SQL queries.
7+
Pure Python Implementation of MySQL replication protocol build on top of PyMYSQL. This allows you to receive event like insert, update, delete with their datas and raw SQL queries.
88

99
Use cases
1010
===========
@@ -56,6 +56,11 @@ Limitations
5656

5757
https://python-mysql-replication.readthedocs.org/en/latest/limitations.html
5858

59+
Featured Books
60+
=============
61+
62+
[Data Pipelines Pocket Reference](https://www.oreilly.com/library/view/data-pipelines-pocket/9781492087823/) (by James Densmore, O'Reilly): Introduced and exemplified in Chapter 4: Data Ingestion: Extracting Data.
63+
5964
Projects using this library
6065
===========================
6166

docker-compose-test.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
version: '3.2'
2+
services:
3+
percona-5.7:
4+
platform: linux/amd64
5+
image: percona:5.7
6+
environment:
7+
MYSQL_ALLOW_EMPTY_PASSWORD: true
8+
MYSQL_DATABASE: pymysqlreplication_test
9+
ports:
10+
- 3306:3306
11+
command: mysqld --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --gtid_mode=on --enforce-gtid-consistency=on --log_slave_updates
12+
restart: always
13+
networks:
14+
- default
15+
16+
percona-5.7-ctl:
17+
image: percona:5.7
18+
environment:
19+
MYSQL_ALLOW_EMPTY_PASSWORD: true
20+
MYSQL_DATABASE: pymysqlreplication_test
21+
ports:
22+
- 3307:3307
23+
command: mysqld --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --gtid_mode=on --enforce-gtid-consistency=on --log_slave_updates -P 3307
24+
25+
pymysqlreplication:
26+
build:
27+
context: .
28+
dockerfile: test.Dockerfile
29+
args:
30+
BASE_IMAGE: python:3.11-alpine
31+
MYSQL_5_7: percona-5.7
32+
MYSQL_5_7_CTL: percona-5.7-ctl
33+
34+
command:
35+
- /bin/sh
36+
- -ce
37+
- |
38+
echo "wait mysql server"
39+
40+
while :
41+
do
42+
if mysql -h percona-5.7 --user=root --execute "USE pymysqlreplication_test;" 2>&1 >/dev/null && mysql -h percona-5.7-ctl --port=3307 --user=root --execute "USE pymysqlreplication_test;" 2>&1 >/dev/null; then
43+
break
44+
fi
45+
sleep 1
46+
done
47+
48+
echo "run pytest"
49+
pytest -k "not test_no_trailing_rotate_event and not test_end_log_pos"
50+
51+
working_dir: /pymysqlreplication
52+
networks:
53+
- default
54+
depends_on:
55+
- percona-5.7
56+
- percona-5.7-ctl
57+
58+
networks:
59+
default: {}

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,23 @@ services:
1515
ports:
1616
- 3307:3307
1717
command: mysqld --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --gtid_mode=on --enforce-gtid-consistency=on --log_slave_updates -P 3307
18+
19+
mariadb-10.6:
20+
image: mariadb:10.6
21+
environment:
22+
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 1
23+
ports:
24+
- "3308:3306"
25+
command: |
26+
--server-id=1
27+
--default-authentication-plugin=mysql_native_password
28+
--log-bin=master-bin
29+
--binlog-format=row
30+
--log-slave-updates=on
31+
volumes:
32+
- type: bind
33+
source: ./.mariadb
34+
target: /opt/key_file
35+
- type: bind
36+
source: ./.mariadb/my.cnf
37+
target: /etc/mysql/my.cnf

docs/developement.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ When it's possible we have an unit test.
2323
*pymysqlreplication/tests/* contains the test suite. The test suite
2424
use the standard *unittest* Python module.
2525

26-
**Be carefull** tests will reset the binary log of your MySQL server.
26+
**Be careful** tests will reset the binary log of your MySQL server.
2727

2828
Make sure you have the following configuration set in your mysql config file (usually my.cnf on development env):
2929

examples/mariadb_gtid/read_event.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pymysql
22

33
from pymysqlreplication import BinLogStreamReader, gtid
4-
from pymysqlreplication.event import GtidEvent, RotateEvent, MariadbGtidEvent, QueryEvent
4+
from pymysqlreplication.event import GtidEvent, RotateEvent, MariadbGtidEvent, QueryEvent,MariadbAnnotateRowsEvent
55
from pymysqlreplication.row_event import WriteRowsEvent, UpdateRowsEvent, DeleteRowsEvent
66

77
MARIADB_SETTINGS = {
@@ -65,10 +65,12 @@ def query_server_id(self):
6565
RotateEvent,
6666
WriteRowsEvent,
6767
UpdateRowsEvent,
68-
DeleteRowsEvent
68+
DeleteRowsEvent,
69+
MariadbAnnotateRowsEvent
6970
],
7071
auto_position=gtid,
71-
is_mariadb=True
72+
is_mariadb=True,
73+
annotate_rows_event=True
7274
)
7375

7476
print('Starting reading events from GTID ', gtid)

0 commit comments

Comments
 (0)