Skip to content

Behavior of model_class in Version 3.0.0a1 #1101

Answered by davidism
jrast asked this question in Q&A
Discussion options

You must be logged in to vote

This was an oversight while rewriting the code, I'll add model.query for existing bases back in.

In general, it's required to subclass Flask-SQLAlchemy classes to get Flask-SQLAlchemy behaviors. Note that you're also missing out on other behaviors, such as automatic table names, bind keys, and a nice repr.

However, the entire query interface is considered legacy in SQLAlchemy now. See the discussion in their docs. SQLAlchemy wants you to move to db.select(User) to construct queries, and db.session.execute(q) to execute them.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jrast
Comment options

@davidism
Comment options

Answer selected by jrast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants