Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将如何在 SQLAlchemy 中编写以下涉及按位与的 SQL 查询?
select * from table where flags & 1 = 1;
表名在哪里table,并且flags是该表中的列名。
table
flags
您想像这样使用按位运算符:
session.query(User).filter(somecolumn.op('&')(1) == 1)
您可以为 OR 编写类似的内容:
session.query(User).filter(somecolumn.op('|')(4) > 4)