loading functions in a q file (kdb)

Viewed 161

I have a q file (./utils/testlib.q) that contains multiple functions defined in it. When I would like to load all the functions in the file in one go, how could we do that?

kdb database runs on a remote linux box and I am trying to load the functions in a file stored in my local PC(windows).

I tried "\l ./utils/testlib.q", but it didn't work as linux box does not know about the directory structure in my local PC (windows)

Thanks

1 Answers

Naturally your remote server can not load files stored locally.

Either A. transfer the file to remote server and load the path where you put it locally to the linux server. (This is probably the best method to keep the file on the box)

B. run a local q process to load / send / define over IPC. I would use a namespace for this. (this will only exist while process is running)

Edit: updated to upsert as per user comment

// send.q
// load functions into namespace
\d .myFunc
\l myFunc.q

/ send over ipc and define in .myFunc namespace server side
`:host:port:user:pass ({`.myFunc upsert x};.myFunc)

Related