【发布时间】:2021-06-30 17:04:49
【问题描述】:
我正在尝试通过 qpython 查询特定函数。该函数需要一个带有多个参数的字典,第一个是日期(类型 -14),第二个是分钟列表(类型 17)。
我写了这个小例子,希望能忠实地说明问题:
\d .test
testfun:{[args]
one:args[`one];
two:args[`two];
' string type args[`two];
:42;
};
现在当我通过 qpython 查询时:
from qpython import qconnection
from qpython.qcollection import QDictionary, qlist
import numpy as np
from qpython.qtype import QLONG_LIST, QSYMBOL_LIST, QMINUTE_LIST
query='{[arg_dict] :.test.testfun[arg_dict] }'
kdbconfig = {
'q_host': 'q_host',
'q_port': 42,
'q_usr': 'q_usr',
'q_pwd': 'q_pwd'
}
params = {
"one" : np.datetime64('2021-01-06', 'D'),
"two" : qlist([ np.timedelta64(10*60, 'm'), np.timedelta64(10*60+30, 'm')] , qtype = QMINUTE_LIST)
}
qparams = QDictionary(list(params.keys()), list(params.values()))
with qconnection.QConnection(host=kdbconfig['q_host'],
port=kdbconfig['q_port'],
username=kdbconfig['q_usr'],
password=kdbconfig['q_pwd'] ) as q:
data = q.sendSync(query, qparams, pandas = True)
if data is None:
raise ValueError("didnt return any data")
但我得到 QException: b'-14' 而我希望输入 17qparams.values 值得:[numpy.datetime64('2021-01-06'), QList([420, 450], dtype='timedelta64[m]')]
所以在我看来是合理的。
请问有人知道如何进行这项工作吗?
【问题讨论】: