================================
Features
--------
This package uses
`mysql-replication <https://github.com/noplay/python-mysql-replication>`__
to read events from MySQL's binlog and send to blinker's signal.
- binlog action level
- schema level
- table level
- row level
It will send RowsEvent only.
Whenever a binlog event come, it will be dispatched into some signals:
#. binlog\_signal: 1 signal for the binlog event.
#. schema\_signal: 1 signal for the event's schema
#. table\_signal: 1 signal for the event's table.
#. row\_signal: 1+ signals for event's rows. 1 signal per row.
Signals
-------
.. code-block::
binlog event -> binlog signal -> schema signal -> table signal --> row signals
So, suppose that an event come with schema=foo, table=bar and it updated
2 rows. Those signal will be sent:
+-----------------+--------------------------+------------------------------+
| signal | signal name | sender |
+=================+==========================+==============================+
| binlog signal | ``update`` | event (RowsEvent) |
+-----------------+--------------------------+------------------------------+
| schema signal | ``update@foo`` | event (RowsEvent) |
+-----------------+--------------------------+------------------------------+
| table signal | ``update@foo.bar`` | event.rows (list of array) |
+-----------------+--------------------------+------------------------------+
| row signal | ``update@foo.bar#row`` | row1 (array) |
+-----------------+--------------------------+------------------------------+
| row signal | ``update@foo.bar#row`` | row2 object (array) |
+-----------------+--------------------------+------------------------------+
Connect to signals
------------------
To connect to a signal, you can use the signal instance or a decorator.
Suppose that you need to connect to write signal on table
*db0.table1*:
.. code-block:: python
from pymysqlblinker import signals
tbl1_signal = signals.table_write('db0', 'table1')
def subscriber1(rows, schema, table):
pass
# use connect function
tbl1_signal.connect(subscriber1)
# or use decorator
@signals.on_table_write('db0', 'table1')
def subscriber1(rows, schema, table):
pass
Signal publishing
-----------------
To start publishing signals
.. code-block:: python
from pymysqlblinker import start_publishing
start_publishing(
'mysql://root@localhost',
)
Replication
-----------
This package support a method to replicate from mysql database. It
operates by keep memory at last binlog position. By default, it save to a file.
To make it, call:
.. code-block:: python
from pymysqlblinker import start_replication
start_replication(
'mysql://root@localhost',
'/path/to/file/that/remember/binlog/position',
)
Change logs
-----------
1.2
~~~
- Add BinlogPosMemory to allow replication: replication is publishing
with
ability to remember last binlog position. For the first run, it will
start at
the end of current binlog.
1.1.1
~~~~~
- Add connect\_timeout argument to pub.start\_publishing
Metadata
Release files for pymysqlblinker 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pymysqlblinker-1.2.tar.gz | 5.8 kB | Without provenance | Details for pymysqlblinker-1.2.tar.gz |
Release files / pymysqlblinker-1.2.tar.gz
| Download URL | pymysqlblinker-1.2.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
107ffa7958f2699a63911ae54ff678903763d0f53b4f87e7341b3ec6225f8039
|
|
BLAKE2b-256 checksum How to use checksums |
9d8f47768141f56f48b7ee0d970779d94309394c4d9d1ffd0c59cfbf639dcf97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pymysqlblinker 1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.