我创建了一个 API 服务,它以 JSON 形式返回股票代码、汇率和日期,但是当我尝试选择多个参数时,它无法正常工作,就像这里的示例一样,假设end_at=2010-05-10和start_at= 2010-05-15:
数据库模型:
class Currency(Base):
__tablename__ = "currency"
ticker = Column(String)
date = Column(Date)
rates = Column(JSONB, primary_key=True)
更新了 Mike Orgenek 的回答中的查询代码:
if end_at and start_at:
currency = cursor.execute("""
SELECT rates,date,ticker
FROM currency
WHERE ticker = %s
AND date BETWEEN SYMMETRIC %s AND %s """, (base, start_at, end_at, ))
start_at打印= 2010-05-10& end_at=的查询后2010-05-15
Out: 2020-07-04T09:32:30.898337+00:00 app[web.1]: b"\n SELECT rates,date,ticker\n FROM currency\n WHERE ticker = 'EUR'\n AND date BETWEEN SYMMETRIC '2010-05-10' AND '2010-05-15' "
start_at即使使用正确的查询FULL API 输出,它也无法识别我的参数
它包括早于start_at类似"2010-01-28", "2010-01-07","2010-04-16"
拉丁的传说
相关分类