Search code examples
sqlpeeweeflask-peewee

peewee: building a query programmatically


Is it possible (how?) to build a select query programmatically in peewee? The point is to add .where() clauses as needed.


Solution

  • query = SomeThing.select()
    if foo:
        query = query.where(SomeThing.value == 'foo')
    else:
        query = query.where(...)