Steffo99 / greed

Customizable, multilanguage Telegram shop bot with Payments support
GNU Affero General Public License v3.0
523 stars 258 forks source link

Greed does not support SQLAlchemy 2.0 #201

Open Steffo99 opened 1 year ago

Steffo99 commented 1 year ago

Discussed in https://github.com/Steffo99/greed/discussions/200

Originally posted by **Daria69lev** February 5, 2023 ubuntu@ip-172-31-59-66:~/bot/greed$ python3 worker.py Traceback (most recent call last): File "/home/ubuntu/bot/greed/worker.py", line 17, in import database as db File "/home/ubuntu/bot/greed/database.py", line 225, in class Order(TableDeclarativeBase): File "/home/ubuntu/.local/lib/python3.10/site-packages/sqlalchemy/orm/decl_api.py", line 199, in __init__ _as_declarative(reg, cls, dict_) File "/home/ubuntu/.local/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 247, in _as_declarative return _MapperConfig.setup_mapping(registry, cls, dict_, None, {}) File "/home/ubuntu/.local/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 328, in setup_mapping return _ClassScanMapperConfig( File "/home/ubuntu/.local/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 559, in __init__ self._scan_attributes() File "/home/ubuntu/.local/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 1001, in _scan_attributes collected_annotation = self._collect_annotation( File "/home/ubuntu/.local/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 1151, in _collect_annotation extracted = _extract_mapped_subtype( File "/home/ubuntu/.local/lib/python3.10/site-packages/sqlalchemy/orm/util.py", line 2306, in _extract_mapped_subtype raise sa_exc.ArgumentError( sqlalchemy.exc.ArgumentError: Type annotation for "Order.items" can't be correctly interpreted for Annotated Declarative Table form. ORM annotations should normally make use of the ``Mapped[]`` generic type, or other ORM-compatible generic type, as a container for the actual type, which indicates the intent that the attribute is mapped. Class variables that are not intended to be mapped by the ORM should use ClassVar[]. To allow Annotated Declarative to disregard legacy annotations which don't use Mapped[] to pass, set "__allow_unmapped__ = True" on the class or a superclass this class. (Background on this error at: https://sqlalche.me/e/20/zlpr)
Steffo99 commented 1 year ago

This should not be happening, unless you are using SQLAlchemy 2.0 instead of the pinned 1.4 version.

Please attach the output of pip freeze in a comment, so I can better diagnose the issue!

Steffo99 commented 1 year ago

(Ping for @Daria69lev, in case the issue conversion did not send a notification.)

Daria69lev commented 1 year ago

ubuntu@ip-172-31-59-66:~/bot/greed$ python3 -OO core.py Traceback (most recent call last): File "/home/ubuntu/bot/greed/core.py", line 241, in main() File "/home/ubuntu/bot/greed/core.py", line 97, in main bot = duckbot.factory(user_cfg)(request=telegram.utils.request.Request(user_cfg["Telegram"]["con_pool_size"])) AttributeError: module 'telegram' has no attribute 'utils'. Did you mean: '_utils'?

Daria69lev commented 1 year ago

new issue

Steffo99 commented 1 year ago

AttributeError: module 'telegram' has no attribute 'utils'. Did you mean: '_utils'?

I'm not sure of what you're doing with your Python installation.

Try installing in a new venv!

laskriabdellah commented 10 months ago

I received the same error while trying to make a test order.

Exception in <Worker 1966753547>: (sqlite3.OperationalError) database is locked [SQL: INSERT INTO orders (user_id, creation_date, delivery_date, refund_date, refund_reason, notes) VALUES (?, ?, ?, ?, ?, ?)] [parameters: (1966753547, '2023-10-03 21:07:55.168630', None, None, None, '')] (Background on this error at: http://sqlalche.me/e/14/e3q8) Traceback (most recent call last): File "/root/greed/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1770, in _execute_context self.dialect.do_execute( File "/root/greed/venv/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 717, in do_execute cursor.execute(statement, parameters) sqlite3.OperationalError: database is locked

Here is the output of my pip freeze

APScheduler==3.6.3 blinker==1.6.2 certifi==2020.12.5 chardet==4.0.0 click==8.1.7 coloredlogs==15.0 flask==3.0.0 greenlet==1.1.0 gunicorn==21.2.0 humanfriendly==9.1 idna==2.10 importlib-metadata==6.8.0 itsdangerous==2.1.2 Jinja2==3.1.2 MarkupSafe==2.1.3 packaging==23.2 python-telegram-bot==13.5 pytz==2021.1 requests==2.25.1 signals==0.0.2 six==1.16.0 SQLAlchemy==1.4.14 toml==0.10.2 tornado==6.1 tzlocal==2.1 urllib3==1.26.5 werkzeug==3.0.0 zipp==3.17.0

Steffo99 commented 10 months ago

Hi @laskriabdellah! Yours seems to be a different issue, #86 specifically!

I'm moving your comment there.