Search code examples
kdb

No table in memory after logout in kdb


When I logout from session my tables are deleted.

What should I do, so when I connect to kdb I see again my tables.

My tables should contain several month data, which added from files incrementally. Also other people should have access to them.

PS: of course, I understand, I could save them to file and then restore. But I need them in memory without saving to any files

Simple example

I load/create table

rlwrap $HOME/l64/l64/q
t:flip `c1`c2`c3!(`a`b`c;42;1.1)

Ctrl+z - logout

rlwrap $HOME/l64/l64/q

no table t


Solution

  • Running rlwrap $HOME/l64/l64/q again opens a new q session. You should not expect to see a table from another session in there.

    If you want to pull data from one q session to another you will need to use ipc. To do this you will need to open a port in your first q session either with a command line flag:

    rlwrap $HOME/l64/l64/q -p 5042
    

    or from within the process itself:

    q)\p 5042
    q)t:flip `c1`c2`c3!(`a`b`c;42;1.1)
    

    Then in a second q process can pull the table over:

    q)h:hopen`::5042
    q)h`t
    c1 c2 c3
    ---------
    a  42 1.1
    b  42 1.1
    c  42 1.1
    q)hclose h
    

    Anyone else on the same server will be able to connect to your port. If your tables are large enough (especially if they're partitioned) you'll want to be careful with what kind of queries that any other user can use. I recommend reading through the Kx white paper on Permissions with kdb+.