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 Re: how to push data to RDB/HDB using pykx

  • 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