I have a table in database
class Foo(Base):
__tablename__ = 'Foo'
id = Column(Integer)
start = Column(Date)
end = Column(Date)
and a python list
dates = [datetime.date(2017, 1, 1), datetime.date(2017, 1, 2), ...].
I want to make the following query
query(Foo, date).filter(Foo.start <= date, Foo.end >= date, date in dates).
The code is illegal, if the objective is not clear, suppose alternative that dates_
is a table in database:
class dates_(Base):
__tablename__ = 'dates_'
date_ = Column(Date)
I want to make a query like the following sqlalchemy code:
query(Foo, dates_.date_).filter(Foo.start <= dates_.date_, Foo.end >= dates_.date_).
Note: psycopg2 seems can turn a list in to sql-queriable.
Comments
Post a Comment