I am trying to write a query which emits the stock data for a given ticker for the current day. My underlying model records the date and time in a datetime field. Currently, I am trying to query by ticker and then time_stamp.
@socketio.on("get initial data")
def on_initial_data(ticker):
"""
Emits the initial stock data for given ticker.
:param str ticker: ticker of stock to query.
"""
socketio.emit("initial data",
[i.serialize for i
in Stock.query.filter_by(
ticker=ticker,
time_stamp=db.func.date(Stock.time_stamp) == date.today()).order_by(Stock.time_stamp)],
room=request.sid)
When this is executed however, I get the error:
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
I am not sure why I am getting this because isn't the db.func.date()
casting?