You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Hi, first of all thanks for your feedback, tbh this is not really a "bug" since it doesn't mention anywhere that it works with MySQL too though having support for MySQL along with postgresql is really good idea! Would you like to create a PR with this change?
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
Actual behaviour
For some reasons 'data' is of type 'str'. ("{}" after
calling __init_database()
)Solution
adding two lines of code at 105:
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.
The text was updated successfully, but these errors were encountered: