Skip to content
Open
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: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ from pymysqlreplication import BinLogStreamReader

mysql_settings = {'host': '127.0.0.1', 'port': 3306, 'user': 'root', 'passwd': ''}

stream = BinLogStreamReader(connection_settings = mysql_settings)
stream = BinLogStreamReader(connection_settings = mysql_settings, server_id=2)

for binlogevent in stream:
binlogevent.dump()
Expand Down Expand Up @@ -322,5 +322,3 @@ 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.


9 changes: 7 additions & 2 deletions pymysqlreplication/binlogstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .event import (
QueryEvent, RotateEvent, FormatDescriptionEvent,
XidEvent, GtidEvent, StopEvent,
BeginLoadQueryEvent, ExecuteLoadQueryEvent,
BeginLoadQueryEvent, ExecuteLoadQueryEvent, IntvarEvent,
NotImplementedEvent)
from .row_event import (
UpdateRowsEvent, WriteRowsEvent, DeleteRowsEvent, TableMapEvent)
Expand Down Expand Up @@ -260,7 +260,11 @@ def __connect_to_stream(self):
if self.log_file is None or self.log_pos is None:
cur = self._stream_connection.cursor()
cur.execute("SHOW MASTER STATUS")
self.log_file, self.log_pos = cur.fetchone()[:2]
output = cur.fetchone()
if not output:
raise Exception('Server is not master')
cur.close()
self.log_file, self.log_pos = output[:2]
cur.close()

prelude = struct.pack('<i', len(self.log_file) + 11) \
Expand Down Expand Up @@ -431,6 +435,7 @@ def _allowed_event_list(self, only_events, ignored_events,
ExecuteLoadQueryEvent,
UpdateRowsEvent,
WriteRowsEvent,
IntvarEvent,
DeleteRowsEvent,
TableMapEvent,
NotImplementedEvent))
Expand Down