试图让一个查询同时在PostgreSQL和SQLite上工作-我需要该查询通过使用数据库列添加iterval来比较datetime
:
end_date = date + timedelta(minutes=duration)
appointment_end_date = Appointment.date + func.make_interval(
0, 0, 0, Appointment.duration
)
existing_lessons = Appointment.query.filter(
or_(
and_(Appointment.date <= end_date, Appointment.date >= date),
and_(appointment_end_date >= date, appointment_end_date <= end_date),
)
).all()
查询试图查找date
变量位于Appointment.date
到Appointment.date + Appointment.duration
内的任何行。如果我可以用timedelta
来写,我会写以下内容:
Appointment.date + timedelta(minutes=Appointment.duration)
目前只适用于PostgreSQL:
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such function: make_interval
有没有可能对这两个数据库进行这样的查询?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐