I want to create a property for a model that contains count.
Since I always need a property, I want to make a query with JOIN as sqlalchemy.orm.relationship with lazy='joined'
For example, I defined models like the following
import sqlalchemy as s, func from sqlalchemy.orm import relatioship
When I access the foo_count property, it will send a request to the DBMS.
Since I always access this property, I want to load its counting property with confidence
SQL will look like this
SELECT id, COUNT(Foo.id) FROM bar INNER JOIN foo ON bar.id = foo.id
Then bar.foo_count will not execute the SQL query.
How to create a property of type foo_count ?
python sqlalchemy
GunWoo Choi
source share