SQLAlchemy如何检查值是否在两列中的值之间?

时间:2014-02-08 08:39:39

标签: python sqlalchemy

如何检查条件值是否在column1和column2之间?

MySQL的:

select
    *
from
    tablename
where
    '2014-01-01' between start_date and end_date

SQLAlchemy的:

select(
  [table.c.id],
  and_('2014-01-01'.between(start_date, end_date))
)

有可能吗?

1 个答案:

答案 0 :(得分:3)

from sqlalchemy import literal

literal('2014-01-01').between(x, y)