I am in the “we don’t need an ORM camp” but what I need instead is a flexible query builder. Like knex for JavaScript. I have yet to find that one.

Does Squirrel cover your needs?

https://github.com/Masterminds/squirrel