I have a sqlalchemy/sqlite table:
class MyTable(Base):
__tablename__ = 'mytable'
...
field_dt = Column(DateTime)
field_int = Column(Integer, default=0)
Now I would like to construct the where condition in which I want to check whether field_dt + field_int (seconds) <= utc_now.
Something like: select(MyTable).where(?).
With no sqlalchemy/sqlite I would construct condition like this:
import datetime as dt
utc_now = dt.datetime(2022,3,2,1,0,10)
field_dt = dt.datetime(2022,3,1,1,0,5)
field_int = 60
print(f" utc_now = {utc_now.isoformat()}")
print(f" field_dt = {field_dt.isoformat()}")
print(f"field_int = {field_int}")
if field_dt + dt.timedelta(seconds=field_int) < utc_now:
print('it is less than utc_now')
Output:
utc_now = 2022-03-02T01:00:10
field_dt = 2022-03-01T01:00:05
field_int = 60
it is less than utc_now
How to do the same with sqlalchemy/sqlite