Skip to main content

Python TiDB binlog replication

Project description

python-tidb-replication
========================

[![Build Status](https://travis-ci.org/HashDataInc/pytidbrep.svg?branch=master)](https://travis-ci.org/HashDataInc/pytidbrep)

Pure Python Implementation of Tidb replication protocol. This allow you to receive event like insert, update, delete with their datas and raw SQL queries.

Use cases
===========

* Tidb to NoSQL database replication
* Tidb to search engine replication
* Invalidate cache when something change in database
* Audit
* Real time analytics

Documentation
==============

TODO

Installation
=============

```
pip install pytidbrep
```

Mailing List
==============

You can get support and discuss about new features on:
https://groups.google.com/forum/#!forum/tidb-user



Examples
=========


This example will dump all replication events to the console:

```python
from pytidbrep import BinLogStreamReader

stream = BinLogStreamReader('/path/to/binlog/dir')

for binlogevent in stream:
print binlogevent

stream.close()
```

For this SQL sessions:

```sql
CREATE DATABASE test;
use test;
CREATE TABLE test4 (id int NOT NULL AUTO_INCREMENT, data VARCHAR(255), data2 VARCHAR(255), PRIMARY KEY(id));
INSERT INTO test4 (data,data2) VALUES ("Hello", "World");
UPDATE test4 SET data = "World", data2="Hello" WHERE id = 1;
DELETE FROM test4 WHERE id = 1;
```

Output will be:

```
391018326269895930: DDL: CREATE DATABASE test;
391018326269895973: DDL: use test; CREATE TABLE test4 (id int NOT NULL AUTO_INCREMENT, data VARCHAR(255), data2 VARCHAR(255), PRIMARY KEY(id));
391018326269896003: DML: INSERT test.test4: data "Hello", id 1, data2 "World",
391018326269896009: DML: UPDATE test.test4: data "Hello" => "World", id 1 => 1, data2 "World" => "Hello",
391018326269896018: DML: DELETE test.test4: data "World", id 1, data2 "Hello",
```


Tests
========
use `tox` to run unit tests


Changelog
==========
[ChangeLog](https://github.com/HashDataInc/pytidbrep/blob/master/ChangeLog)


Contributors
==============

Major contributor:

* [Zhanwei Wang](https://github.com/wangzw)


Licence
=======
Copyright 2012-2017 HashData Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytidbrep-1.0.6.tar.gz (27.4 kB view details)

Uploaded Source

File details

Details for the file pytidbrep-1.0.6.tar.gz.

File metadata

  • Download URL: pytidbrep-1.0.6.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pytidbrep-1.0.6.tar.gz
Algorithm Hash digest
SHA256 ee0f05d12c79c13ad5db37a82cbfb1b2c7d9be020ef11f8d292faa6cfea2c247
MD5 2f23c6381504baa55a514cb16cb5e0dd
BLAKE2b-256 c555712394b3fafd3ed10ca8c98a78e10ef474cae0bd89f8c4204107308cd777

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page