如何将 TIMESTAMPDIFF 添加到 SqlSoup 查询?
我有一个正在运行并使用 SqlSoup 的报告程序,并且现在通过 SqlSoup 调用生成了整个查询(MySqL 函数 TIMESTAMPDIFF
除外)。
实际的 SQL 短语应该是
TIMESTAMPDIFF(PERIOD, start_time, end_time) <= 60
我尝试过的
from sqlalchemy.sql.expression import func
和一个 where 子句短语(使用 rc
对数据库和表的引用)
where = and_(where, func.TIMESTAMPDIFF('PERIOD',rc.start_time,rc.end_time) <= 60)
这可以编译,但登录后会显示 PERIOD
作为 %s
和参数 PERIOD
下面,这似乎不起作用。
对于使用 SqlSoup 执行此操作有什么想法吗?
I have a reporting program running and using SqlSoup and have the entire query generated now by SqlSoup calls except for the MySqL Function TIMESTAMPDIFF
.
The actual SQL phrase should be
TIMESTAMPDIFF(PERIOD, start_time, end_time) <= 60
I tried
from sqlalchemy.sql.expression import func
and a where-clause phrase (with rc
a reference to the database and table)
where = and_(where, func.TIMESTAMPDIFF('PERIOD',rc.start_time,rc.end_time) <= 60)
This compiles, but with logging on it shows the PERIOD
as %s
and then a parameter PERIOD
below, which does not seem to work.
Any ideas for doing this with SqlSoup?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

在这种情况下,
sqlalchemy.text()
是你的朋友:-)尝试:
sqlalchemy.text()
is your friend in this case :-)Try: