I'm trying to query KDB with the following select statement: {select from order where OrderID = x}
. When passing in the parameter it keeps throwing b'lenghth exceptions. I've tried numpy.string_
, numpy.bytes_
and regular bytes
using the .encode()
method (latin-1 and utf-8).
When I query one record to investigate the type of the OrderID column, it tells me the column type is bytes
.
What am I doing wrong? Not sure what the dash in the docs is supposed to mean. Thanks!
It sounds like the type of OrderID
on the kdb side is a character list. In which case you need to use like
to do the comparison in your query:
{select from order where OrderID like x}
And then you should be able to use a regular Python string for the parameter, .e.g.
q.sync("{select from order where OrderID like x}", "my_order_id")
As long as you don't use any wildcard characters in parameter x
then this will only match on the exact string. i.e.
q)"one" like "one"
1b
q)"ones" like "one"
0b
q)"ones" like "one*"
1b