-
Notifications
You must be signed in to change notification settings - Fork 43
Description
PTB_sqlalchemy_persistence
Because other data in the project is already stored in mysql i've tried to adapt the code for using mysql instead of postgres. (And never run postgres myself, maybe this is already the source of the bug.)
Steps to reproduce
- Altering the test for postgres-uri in line 71.
- Use sqlalchemy-scoped-session bound to a mysql-database.
- start the updater
Actual behaviour
File "persistence.py", line 108, in __load_database:
self._chat_data = defaultdict(dict, self._key_mapper(data.get("chat_data", {}), int))
AttributeError: 'str' object has no attribute 'get'
For some reasons 'data' is of type 'str'. ("{}" after calling __init_database()
)
Solution
adding two lines of code at 105:
if isinstance(data, str):
data = json.loads(data)
Version of Python, python-telegram-bot & dependencies:
$ python -m telegram
python-telegram-bot 13.11
Bot API 5.7
certifi 2021.10.08
Python 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)]
mysql 8.0
sqlalchemy 1.4.27
conda 4.11.0
Windows 11
I thought somebody could find this interessting. Apart from this minor fix could this module named more general.