I created an API service that returns ticker,rate and date as JSON, But when i'm trying to select multiple parameters, it doesn't works properly like here is an example,lets say end_at = 2010-05-10 and start_at = 2010-05-15:
Datebase model:
class Currency(Base):
__tablename__ = "currency"
ticker = Column(String)
date = Column(Date)
rates = Column(JSONB, primary_key=True)
Updated query code from Mike Orgenek's answer:
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, ))
After printing the query for 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' "
It doesn't recognizes my start_at parameter even with the right query FULL API Output
It includes dates older than the start_at like "2010-01-28", "2010-01-07", "2010-04-16"
executestep and examine what is actually being constructed in your query.cursor.execute()