如何使用 qPython 向 KDB 中插入一行

How to insert a row into KDB using qPython

我正在尝试使用脚本连接到 KDB 并使用 qpython (https://github.com/exxeleron/qPython) 将行插入 KDB 中的 table。我的 table 具有以下列类型:
"symbol","symbol","int","timestamp","string","string","symbol","symbol","string","string","string"

我试过使用 '.u.upd' 但是这个 returns 什么也没有更新 table:

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)

当我尝试使用 insert 时,出现错误 'type:

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"))')

感谢任何帮助。

在使用插入时,您应该通过引用而不是通过值来传递表名,即

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 具体只存在于 realtime/tickerplant 设置中,而不是内置的 q 函数。