julien-duponchelle / python-mysql-replication

Pure Python Implementation of MySQL replication protocol build on top of PyMYSQL
2.32k stars 679 forks source link

No module named 'pymysqlreplication.util' #504

Closed shancz closed 1 year ago

shancz commented 1 year ago

Hi,

Following the install of the mysql-replication module as such. pip install mysql-replication

I copied the caching example from here: https://github.com/julien-duponchelle/python-mysql-replication/blob/master/examples/redis_cache.py

I am getting the following error message: No module named 'pymysqlreplication.util'

full error message:

$ python redis_cache.pyTraceback (most recent call last): File "redis_cache.py", line 13, in from pymysqlreplication import BinLogStreamReader File "/home/ec2-user/optimize-cost-on-rdbms-using-amazon-elasticache-main/.venv/lib64/python3.8/site-packages/pymysqlreplication/init.py", line 23, in from .binlogstream import BinLogStreamReader File "/home/ec2-user/optimize-cost-on-rdbms-using-amazon-elasticache-main/.venv/lib64/python3.8/site-packages/pymysqlreplication/binlogstream.py", line 11, in from .event import ( File "/home/ec2-user/optimize-cost-on-rdbms-using-amazon-elasticache-main/.venv/lib64/python3.8/site-packages/pymysqlreplication/event.py", line 11, in from pymysqlreplication.util.bytes import parse_decimal_from_bytes ModuleNotFoundError: No module named 'pymysqlreplication.util'

Regards, Steven

peterlupu commented 1 year ago

yeah same here with binlog dump_events example

i just installed earlier release and it seems to work fine

pip install mysql-replication==0.44.0
shancz commented 1 year ago

thank you!

shancz commented 1 year ago

The next error I am seeing is related to missing server id.

Traceback (most recent call last): File "redis_cache.py", line 67, in main() File "redis_cache.py", line 45, in main stream = BinLogStreamReader( TypeError: init() missing 1 required positional argument: 'server_id'

Any idea what should be passed in?

shancz commented 1 year ago

I fond it redis_cache stream reader is missing the server_id parameter.

from examples/dump_events.py the stream is created with the server_id.

stream = BinLogStreamReader(connection_settings=MYSQL_SETTINGS,
                            server_id=3,
                            blocking=True)
sean-k1 commented 1 year ago

@shancz @peterlupu i'm sorry guys. There was a problem when publishing. If you are a mysql5.7 user, please check 0.45.1.

peterlupu commented 1 year ago

@shancz @peterlupu

i'm sorry guys.

There was a problem when publishing. If you are a mysql5.7 user, please check 0.45.1.

Hey. I'm actually testing on mariadb 10.x

Will check

peterlupu commented 1 year ago

hey

pip install  mysql-replication==0.45.1

works

but installing latest (1.0.1)

gives me

Traceback (most recent call last):
  File "/Users/peter/code/pymsqlbinlog/dump_events.py", line 8, in <module>
    from pymysqlreplication import BinLogStreamReader
  File "/Users/peter/code/pymsqlbinlog/venv/lib/python3.10/site-packages/pymysqlreplication/__init__.py", line 23, in <module>
    from .binlogstream import BinLogStreamReader
  File "/Users/peter/code/pymsqlbinlog/venv/lib/python3.10/site-packages/pymysqlreplication/binlogstream.py", line 34, in <module>
    from .packet import BinLogPacketWrapper
  File "/Users/peter/code/pymsqlbinlog/venv/lib/python3.10/site-packages/pymysqlreplication/packet.py", line 3, in <module>
    from pymysqlreplication import constants, event, row_event
  File "/Users/peter/code/pymsqlbinlog/venv/lib/python3.10/site-packages/pymysqlreplication/row_event.py", line 12, in <module>
    from .constants import CHARSET
  File "/Users/peter/code/pymsqlbinlog/venv/lib/python3.10/site-packages/pymysqlreplication/constants/CHARSET.py", line 57, in <module>
    with open(
FileNotFoundError: [Errno 2] No such file or directory: '/Users/peter/code/pymsqlbinlog/venv/lib/python3.10/site-packages/pymysqlreplication/constants/charset_list.csv'

note that i'm running python 3.10 and the project says "Python 3.3, 3.4, 3.5 and 3.6 (3.2 is not supported)" so it might be on my end

cheers

sean-k1 commented 1 year ago

@peterlupu when I pip install mysql-replication==0.45.1 It look's fine i'll fix that error thanks !