Python Postgres:在日期字段上的位置

时间:2019-06-28 20:04:07

标签: python postgresql date filter sqlalchemy

我用“日期”字段定义了一个表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)
    )

1 个答案:

答案 0 :(得分:0)

session.select([ABC]).where(ABC.date == '2019-06-26')