Using SQL query within the console:
select * from trades_one where traded_ts > dateadd('d', -1, now());
OK
Using HTTP REST API
q = "select traded_price,"\
" limit_price,"\
" qty,"\
" traded_ts,"\
" timestamp"\
" from trades_one"\
" where traded_price < 1.6"
query = urllib.parse.quote(q)
r = requests.get("http://localhost:9000/exp?query=" + query)
queryData = r.content
rawData = pd.read_csv(io.StringIO(queryData.decode('utf-8')), parse_dates=['timestamp'])
print(rawData)
OK
now I wish to call this date-time function within the query:
dateadd('d', -1, now()
for result:
Empty DataFrame
Columns: [{"query":"select traded_price, limit_price, qty, traded_ts, timestamp from trades_one where traded_ts > dateadd('d', -1, now()", error:"unbalanced (", position:101}]
Index: []
Current syntax:
q = "select traded_price,"\
" limit_price,"\
" qty,"\
" traded_ts,"\
" timestamp"\
" from trades_one"\
" where traded_ts > dateadd('d', -1, now()"
How do I embed this date-time function dateadd('d', -1, now()
into the HTTP REST API
python query?
Documentation for the function:
https://questdb.io/docs/reference/function/date-time
Any guidance appreciated.
well i forgot a )
" limit_price,"\
" qty,"\
" traded_ts,"\
" timestamp"\
" from trades_one"\
" where traded_ts > dateadd('d', -1, now())"
works now - will leave the post up because someone else might find it useful on how to construct a query.