我正在使用 SQLObject,一个用于管理 SQL 查询的 Python 包装器,以及 Python 2.7。我知道我可以使用字典来选择数据,例如:
restrictions = { ... }
selection = sql_table.selectBy(**restrictions).orderBy('-createdtime')
我还可以通过以下方式查询日期:
selection = sql_table.select(sql_table.q.creatdtime>=datetime.datetime(year, month, day, 0, 0, 0, 0)
但是,我想同时使用两者来按日期和字典配对排序。当我尝试像这样将它们放在一起时:
selection = sql_table.select(**restrictions, sql_table.q.creatdtime>=datetime.datetime(year, month, day, 0, 0, 0, 0)
它不起作用。有没有办法按日期时间范围和字典配对过滤 SQL 查询?