-
how to push data to RDB/HDB using pykx
Posted by renbright on January 8, 2024 at 12:00 amhow to push data to RDB/HDB using pykx?
renbright replied 8 months, 3 weeks ago 4 Members · 9 Replies -
9 Replies
-
Hi ,
If possible could you elaborate a little more on your use case and the issue youre running into?
-
we are using pykx to load data from kdb database and want to send data back to kdb after doing some operation:
1. in qConnection, sendSync can read/write data from/to kdb
2. what about pykx?
-
If you have access to the KX Insights services, you could use the Python interface to Insights to publish data, which your RDB could subscribe to,
https://code.kx.com/insights/microservices/rt/sdks/python-sdk.html
https://code.kx.com/insights/1.8/microservices/rt/index.html
-
Here is a basic example if you wanted to send some data from a Pandas Dataframe
>>> import pykx as kx >>> import pandas as pd >>> import numpy as np >>> conn = kx.SyncQConnection('localhost', 5000) >>> df = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), columns=['a', 'b', 'c']) >>> conn('tab:([]a:`long$();b:`long$();c:`long$())') pykx.Identity(pykx.q('::')) >>> conn('insert','tab',df) pykx.LongVector(pykx.q('0 1 2')) >>> conn('tab') pykx.Table(pykx.q(' a b c ----- 1 2 3 4 5 6 7 8 9 '))
The documentation website has more examples
-
For python interface, which one should I pick and install?
-
The exact install steps, including the URL you’ll want to install is on the page below,
https://code.kx.com/insights/1.8/microservices/rt/sdks/python-sdk.html#installation
Also, here’s an image of what you want
-
anyone has any suggestions for pushing data to tickerplant and then to rdb? I have the following error.
-
Hi it appears that the issue is in the logic on the server side `.u.upd` function, unfortunately I haven’t been able to replicate it locally with the equivalent table you are looking to use. Could you provide some information as to the expected inputs and logic of your upd function?
-
Thanks for your reply. I am good now. currently my .u.upd does not take table as input. it works after I converted table into list: flip = kx.q(‘flip’); ticker(‘.u.upd’,’ustrisk’, flip (df.values.tolist()))
is there any good way to upsert list/dataframe to HDB table?
Log in to reply.