python - 如何使用 qPython 在 KDB 中插入一行
问题描述
我正在尝试使用脚本连接到 KDB 并使用 qpython (https://github.com/exxeleron/qPython)将行插入到 KDB 中的表中。我的表具有以下列类型:
"symbol","symbol","int","timestamp","string","string","symbol","symbol","string","string","string"
我尝试使用'.u.upd'
,但这不返回任何内容并且不更新表:
time = [numpy.timedelta64((numpy.datetime64(datetime.now()) - today), 'ms') for x in range(1)]
row = [qlist(['test'], qtype=QSYMBOL_LIST), qlist(['test'], qtype=QSYMBOL_LIST), qlist([1], qtype=QINT_LIST), qlist(time, qtype=QTIME_LIST),
qlist([['t','e','s','t']], qtype=QSTRING_LIST), qlist([['t','e','s','t']], qtype=QSTRING_LIST), qlist(['test'], qtype=QSYMBOL_LIST), qlist(['test'], qtype=QSYMBOL_LIST),
qlist([['t','e','s','t']], qtype=QSTRING_LIST), qlist([['t','e','s','t']], qtype=QSTRING_LIST), qlist([['t','e','s','t']], qtype=QSTRING_LIST)]
result = self.q.sendSync('.u.upd', numpy.string_('tableName'), row)
当我尝试使用插入时,我收到错误“类型:
result = self.q('tableName insert (`test;`test;1i;2019.08.09D12:00:00.123123123;("t"; "e"; "s"; "t");("t"; "e"; "s"; "t");`test;`test;("t"; "e"; "s"; "t");("t"; "e"; "s"; "t");("t"; "e"; "s"; "t"))')
任何帮助表示赞赏。
解决方案
使用插入时,您应该通过引用而不是值传递表名,.ie
result = self.q('`tableName insert (`test;`test;1i;2019.08.09D12:00:00.123123123;("t"; "e"; "s"; "t");("t"; "e"; "s"; "t");`test;`test;("t"; "e"; "s"; "t");("t"; "e"; "s"; "t");("t"; "e"; "s"; "t"))')
注意表名前面的反引号。
对于您的其他问题,.u.upd
具体仅存在于实时/自动报价系统设置中,而不是内置的 q 函数。
推荐阅读
- javascript - 如何从对象数组中填充多个输入字段
- java - 具有固定初始值的累积差
- kotlin - Kotlin 是否有与 swift 中的“DispatchWorkItem”完全相同的东西?
- html - 网站 no_id yes_class getelement 然后点击
- javascript - Mock imported function with jest in an await context
- javascript - Asynchronous code in nested forEach loop- react native
- python - AttributeError when using ColumnTransformer into a pipeline
- html - Display Flex in Safari align
- r - 从原始向量创建数据框
- javascript - 在没有模块加载器的 ES6 模块系统(在浏览器中)中使用 rxjs