【发布时间】:2016-08-19 17:47:57
【问题描述】:
我在 Python 2.7 中使用 SQLObject,一个用于管理 SQL 查询的 Python 包装器。我知道我可以使用字典来选择数据,例如:
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 查询?
【问题讨论】:
标签: python mysql python-2.7 dictionary sqlobject