KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums PyKX how to push data to RDB/HDB using pykx

  • cmccarthy1

    Member
    January 8, 2024 at 12:00 am

    Hi ,

    If possible could you elaborate a little more on your use case and the issue youre running into?

  • renbright

    Member
    January 8, 2024 at 12:00 am

    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?

  • dwalshq

    Member
    January 9, 2024 at 12:00 am

    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

     

     

  • rocuinneagain

    Member
    January 9, 2024 at 12:00 am

    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

    https://code.kx.com/pykx

     

     

  • renbright

    Member
    January 10, 2024 at 12:00 am

    For python interface, which one should I pick and install?

     

     

     

  • dwalshq

    Member
    January 10, 2024 at 12:00 am

    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

     

     

  • renbright

    Member
    January 11, 2024 at 12:00 am

    anyone has any suggestions for pushing data to tickerplant and then to rdb? I have the following error.

     

     

  • cmccarthy1

    Member
    January 11, 2024 at 12:00 am

    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?

  • renbright

    Member
    January 11, 2024 at 12:00 am

    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.