Where in query with and
benvindo opened this issue · comments
Bruno Costa commented
Hi,
How to use 'where' with the conditional 'and'? I tried use like this: but not working:
where=(self.proxy.c.qtd_uso != 0 and self.proxy.c.tentativa_uso<=10)
Thomas Perl commented
Try this: where=(self.proxy.c.qtd_uso != 0 & self.proxy.c.tentativa_uso <= 10)
The implementation detail reason being that it's possible to override the &
operator, but not the and
operator.
Thomas Perl commented
This is actually also documented (not explicitly, though) in the example README:
>>> Person.load(db, (Person.c.age >= 16) & (Person.c.age <= 50))