【问题标题】:Python Postgres: WHERE on a date-FieldPython Postgres:日期字段上的 WHERE
【发布时间】:2019-06-28 20:04:07
【问题描述】:

我用字段“日期”定义了一个表 ABC。 设置日期过滤器无效。我得到所有条目。如果我结合过滤器(id='...' 和 date='...')只有 id 过滤器有效果...

有人知道我可以如何过滤吗?

ABC= Table("abc", METADATA,
    Column("id", UUID, primary_key=True),
    Column("zzz_id", UUID, ForeignKey("zzz.id"), nullable=False),
    ...
    Column("date", Date, nullable=False)
)

session.select(
        ABC,
        # where= ABC.c.date == '2019-06-26'
        # where= ABC.c.date == datetime.date(2019, 6, 26)
        # where= ABC.c.date == datetime.datetime(2019, 6, 26)
    )

【问题讨论】:

标签: python postgresql date filter sqlalchemy


【解决方案1】:
session.select([ABC]).where(ABC.date == '2019-06-26')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-05
    • 2021-11-25
    • 1970-01-01
    • 2021-06-25
    相关资源
    最近更新 更多