SQLAlchemy: create an intentionally empty query?

If you need the proper return type, just return session.query(MyObject).filter(sqlalchemy.sql.false()).

When evaluated, this will still hit the DB, but it should be fast.

If you don’t have an ORM class to “query”, you can use false() for that as well:
session.query(sqlalchemy.false()).filter(sqlalchemy.false())

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)