所以我运行下面的查询没有问题:qpython.sync()返回一个QProjection,而不是查询的数据
print(self.data_source.connections['history'].sync(
'{[x;y;z]select from trade where date within(x;y), sym in z}',
numpy.datetime64('2014-04-14', 'D'),
numpy.datetime64('2017-08-14', 'D'),
NumpyUtil.parse_symbols(['instr81', 'instr61', 'instr26'])
))
这里self.data_source.connections[]
仅仅是一个与tickerplant,建屋局和RDB的连接和字典NumpyUtil.parse_symbols()
是一个小方法,将参数解析为正确的Numpy类型(已成功测试)。
它产生的是以下并且是涉嫌结果:
[ ('2017-07-20', b'instr26', 31538122, b'instr14', 93.87083689, 77.0477359 , 81)
('2017-07-20', b'instr26', 31543119, b'instr72', 27.69372507, 80.00145357, 8)
('2017-07-20', b'instr26', 31678121, b'instr56', 58.24375362, 13.93626591, 36)
...,
('2017-07-26', b'instr81', 55344040, b'instr95', 18.75910878, 63.28561637, 98)
('2017-07-26', b'instr81', 81898858, b'instr78', 34.76710694, 8.32085477, 69)
('2017-07-26', b'instr81', 81938857, b'instr97', 64.54823106, 0.16524401, 81)]
完美:)
当我把它变成这种包装方法我的问题出现了:
def synced_query(self, database, query, parameters):
print(self.connections[database].sync(query, parameters))
当通过确切相同的参数,它返回的东西,QProjection:
QProjection(QLambda('{[x;y;z]select from trade where date within(x;y),sym in z}'), [numpy.datetime64('2012-06-20'), numpy.datetime64('2017-07-30'), QList([b'instr81', b'instr61', b'instr26'],
dtype='|S7')])
现在我已经通过我的代码看(数据在synced_query()
方法结束之前通过一些功能通过周围),但我认为该数据被分析并正确地传递。
当我看文档q.sync()
方法应该只返回从kdb返回的消息,否则引发异常。
所以我基本上想知道为什么kdb给了我这样一个奇怪的答案。有任何想法吗? :)
感谢队友,解决了这个问题。我的理解是,我只需要它在参数部分(我已经删除它只是为了看看会发生什么)。不知道'拆包'。谢谢! –