python-mysql-replication icon indicating copy to clipboard operation
python-mysql-replication copied to clipboard

Graceful exit when connect to mysql whose bin-log is not enable

Open cutewalker opened this issue 8 years ago • 1 comments

When connect to a mysql whose bin-log is not enable, an error raise without any useful hint:

$ python dump_events.py
Traceback (most recent call last):
  File "dump_events.py", line 33, in <module>
    main()
  File "dump_events.py", line 26, in main
    for binlogevent in stream:
  File "<the-python-site-packages>/pymysqlreplication/binlogstream.py", line 371, in fetchone
    self.__connect_to_stream()
  File "<the-python-site-packages>/pymysqlreplication/binlogstream.py", line 279, in __connect_to_stream
    self.log_file, self.log_pos = cur.fetchone()[:2]
TypeError: 'NoneType' object is not subscriptable

From the source, we know this is because show master status return Empty set.

So, a graceful exit message or a custom exception here would be much nice.

cutewalker avatar Dec 22 '16 07:12 cutewalker

pull requests welcome :)

baloo avatar Dec 22 '16 11:12 baloo