1

I'm trying to use a script to connect to a KDB and insert rows into a table in the KDB using qpython (https://github.com/exxeleron/qPython). My table has the following column types:
"symbol","symbol","int","timestamp","string","string","symbol","symbol","string","string","string"

I tried using '.u.upd' but this returns nothing and does not update the 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)

When I try using insert I get the error '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"))')

Any help is appreciated.

1 Answer 1

1

You should pass the tablename by reference not by value when using insert, .i.e.

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

Note the backtick in front of the tablename.

For your other issue, .u.upd specifically only exists in a realtime/tickerplant setup and is not a built-in q function.

Sign up to request clarification or add additional context in comments.

2 Comments

Probably worth mentioning that it's only defined in vanilla kdb+tick. So not necessarily defined in all tick setups if you don't use the vanilla scripts
Thanks this worked for me! After I added the backtick to the table name, I got a 'length error and had to add a timestamp to my insert list. After that I was able to insert.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.