kdb+

How do you run system commands like loading a db over a handle


I've connected to a process and I want to load a db into it from another process. How do you do this in kdb+ as you can't use system"" because it clashes with handle""


Solution

  • You need to escape the quotation marks

    h"system\"p\""

    But better to use a list (edit: I had parse tree which is wrong as pointed out by Igor) when sending queries over IPC. One of the reasons for that is exactly the issue you run into.

    h:hopen 9999                                                                                           
    h"system\"p\""                                                                                          q)
    9999i                                                                                                   
    h(system;"p")                                                                                           
    9999i                                                                                                   
    q)    
    

    You can read about parse trees here https://code.kx.com/q/basics/parsetrees/ and here https://www.defconq.tech/docs/concepts/functionalSelect