<commit_before>Python MySQL Replication Blinker
================================

    Test travis-ci build

> Underconstruction 

This package uses [mysql-replication](https://github.com/noplay/python-mysql-replication) to read
events from MySQL binlog and send to blinker's signal.

It will send RowsEvent only.

Whenever a binlog event come, it will be dispatched into some signals:

1. 1 signal for the binlog event.
2. 1 signal for the event's rows.
3. 1+ signals for event's rows. 1 signal per row.


Signals
-------

### Signal name

The signal name has formation as :

    action@schema.table[#row|#rows]

So, suppose that an event come with schema=foo, table=bar and it updated 2 rows. Those signal will be sent:


|      signal name      |    sender    |
| --------------------- | ------------ |
| `<EMAIL>`      | event object |
| `<EMAIL>#rows` | event's rows |
| `<EMAIL>#row`  | row1 object  |
| `<EMAIL>#row`  | row2 object  |<commit_msg>documentation<commit_after>Python MySQL Replication Blinker
================================

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:

1. binlog_signal: 1 signal for the binlog event.
2. schema_signal: 1 signal for the event's schema
3. table_signal: 1 signal for the event's table.
4. row_signal: 1+ signals for event's rows. 1 signal per row.


Signals
-------

    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  | `<EMAIL>`     | event.rows (list of array) |
| row signal    | `<EMAIL>#row` | row1  (array)              |
| row signal    | `<EMAIL>#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*:

    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


    
{'fraction_non_alphanumeric': 0.15570565232847494, 'fraction_numerical': 0.01173124777817277, 'mean_word_length': 2.548549810844893, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2290731', 'n_tokens_mistral': 859, 'n_tokens_neox': 794, 'n_words': 306}