thp / minidb

Store Python objects in SQLite 3. Concise, pythonic API. Easy to write, relatively easy to read. A kind of super simple ORM, if you will. Give it a try.

Home Page:https://thp.io/2010/minidb/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Where in query with and

benvindo opened this issue · comments

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)

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.

This is actually also documented (not explicitly, though) in the example README:

>>> Person.load(db, (Person.c.age >= 16) & (Person.c.age <= 50))