Re: [sqlalchemy] limit in context of entities not rows

2019-07-04 Thread Simon King
I would first figure out how you would do this in SQL, and then translate that to SQLAlchemy. In this case, the EXISTS operator might work: SELECT * FROM department WHERE EXISTS ( SELECT 1 FROM employee WHERE employee.department_id = department.id AND employee.name IN (...) )

[sqlalchemy] limit in context of entities not rows

2019-07-04 Thread Victor Olex
Using ORM querying what is the best practice for limiting the output to a given number of resulting *entities*? Consider this model: from sqlalchemy import Column, DateTime, String, Integer, ForeignKey, func from sqlalchemy.orm import relationship, backref from sqlalchemy.ext.declarative import