Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name '_QueryProperty' from 'flask_sqlalchemy' #1307

Closed
fatjan opened this issue Jan 30, 2024 · 1 comment
Closed

Comments

@fatjan
Copy link

fatjan commented Jan 30, 2024

I am using Flask-SQLAlchemy version 3.1.1
and I have the following import error issue:

ImportError: cannot import name '_QueryProperty' from 'flask_sqlalchemy'

File "/Users/user/.pyenv/versions/3.9.16/lib/python3.9/site-packages/flask_appbuilder/models/sqla/__init__.py", line 5, in <module>

Screenshot 2024-01-30 at 12 17 52

Replicate:
use Flask-SQLAlchemy version 3.1.1 in a Flask app

Expected behaviour:
the _QueryProperty should be successfully imported from flask_sqlalchemy without any issue

Environment:

  • Python version: 3.9.16
  • Flask-SQLAlchemy version: 3.1.1
  • SQLAlchemy version: 2.0.23
@davidism
Copy link
Member

That's no longer available, as the internal API has changed significantly in version 3. It was not marked as part of the public API. Note that the query API is considered legacy in SQLAlchemy 2, and you should migrate to its new execution API when possible. SQLAlchemy also provides it directly: https://docs.sqlalchemy.org/en/20/orm/contextual.html#sqlalchemy.orm.scoped_session.query_property

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants