Skip to content

Minor improvements #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from Jul 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/binlogstream.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###################
##################
BinLogStreamReader
###################
##################


.. automodule:: pymysqlreplication.binlogstream
Expand Down
4 changes: 2 additions & 2 deletions docs/events.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###################
######
Events
###################
######

.. automodule:: pymysqlreplication.event
:members:
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Contents:
licence

Contributing
==============
============
You can report issues and contribute to the project on:
https://github.com/noplay/python-mysql-replication

Expand Down
4 changes: 2 additions & 2 deletions docs/support.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
########
#######
Support
########
#######

You can get support and discuss about new features on:
https://groups.google.com/d/forum/python-mysql-replication
Expand Down
5 changes: 1 addition & 4 deletions examples/logstash/mysql_to_logstash.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# python examples/logstash/mysql_to_logstash.py | java -jar logstash-1.1.13-flatjar.jar agent -f examples/logstash/logstash-simple.conf

import json
import time
import sys

from pymysqlreplication import BinLogStreamReader
Expand All @@ -33,9 +32,7 @@ def main():

for binlogevent in stream:
for row in binlogevent.rows:
event = {}
event["schema"] = binlogevent.schema
event["table"] = binlogevent.table
event = {"schema": binlogevent.schema, "table": binlogevent.table}

if isinstance(binlogevent, DeleteRowsEvent):
event["action"] = "delete"
Expand Down
12 changes: 6 additions & 6 deletions pymysqlreplication/row_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection):
self.number_of_columns = self.packet.read_length_coded_binary()
self.columns = self.table_map[self.table_id].columns

#Aditionnal informations
# Additional information
self.schema = self.table_map[self.table_id].schema
self.table = self.table_map[self.table_id].table

Expand Down Expand Up @@ -141,7 +141,7 @@ def _read_column_data(self, null_bitmap):
return values

def __add_fsp_to_time(self, time, column):
"""Read and add the fractionnal part of time
"""Read and add the fractional part of time
For more details about new date format:
http://dev.mysql.com/doc/internals/en/date-and-time-data-type-representation.html
"""
Expand All @@ -161,10 +161,10 @@ def __add_fsp_to_time(self, time, column):
return time

def __read_string(self, size, column):
str = self.packet.read_length_coded_pascal_string(size)
string = self.packet.read_length_coded_pascal_string(size)
if column.character_set_name is not None:
str = str.decode(column.character_set_name)
return str
string = string.decode(column.character_set_name)
return string

def __read_bit(self, column):
"""Read MySQL BIT type"""
Expand Down Expand Up @@ -503,7 +503,7 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection):
self.table_obj = Table(self.column_schemas, self.table_id, self.schema,
self.table, self.columns)

# TODO: get this informations instead of trashing data
# TODO: get this information instead of trashing data
# n NULL-bitmask, length: (column-length * 8) / 7

def get_table(self):
Expand Down
2 changes: 1 addition & 1 deletion pymysqlreplication/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class PyMySQLReplicationTestCase(unittest.TestCase):
"""Test the module. Be carefull it will reset your MySQL server"""
"""Test the module. Be careful it will reset your MySQL server"""
database = {
"host": "localhost",
"user": "root",
Expand Down
18 changes: 8 additions & 10 deletions pymysqlreplication/tests/test_data_type.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# -*- coding: utf-8 -*-

import copy
import datetime
import platform
import unittest

from decimal import Decimal

from pymysqlreplication.tests import base
from pymysqlreplication.event import *
from pymysqlreplication.constants.BINLOG import *
from pymysqlreplication.row_event import *

Expand Down Expand Up @@ -405,26 +403,26 @@ def test_encoding_latin1(self):
self.connect_conn_control(db)

if platform.python_version_tuple()[0] == "2":
str = unichr(233)
string = unichr(233)
else:
str = "\u00e9"
string = "\u00e9"

create_query = "CREATE TABLE test (test CHAR(12)) CHARACTER SET latin1 COLLATE latin1_bin;"
insert_query = b"INSERT INTO test VALUES('" + str.encode('latin-1') + b"');"
insert_query = b"INSERT INTO test VALUES('" + string.encode('latin-1') + b"');"
event = self.create_and_insert_value(create_query, insert_query)
self.assertEqual(event.rows[0]["values"]["test"], str)
self.assertEqual(event.rows[0]["values"]["test"], string)

def test_encoding_utf8(self):
if platform.python_version_tuple()[0] == "2":
str = unichr(0x20ac)
string = unichr(0x20ac)
else:
str = "\u20ac"
string = "\u20ac"

create_query = "CREATE TABLE test (test CHAR(12)) CHARACTER SET utf8 COLLATE utf8_bin;"
insert_query = b"INSERT INTO test VALUES('" + str.encode('utf-8') + b"')"
insert_query = b"INSERT INTO test VALUES('" + string.encode('utf-8') + b"')"

event = self.create_and_insert_value(create_query, insert_query)
self.assertMultiLineEqual(event.rows[0]["values"]["test"], str)
self.assertMultiLineEqual(event.rows[0]["values"]["test"], string)


if __name__ == "__main__":
Expand Down