I want to connect a hdb database inside a kdb .q
script and query inside a script, not directly on the q prompt.
The code that I now have inside abc.q
is:
h:hopen `:url:port:userid:pwd
h"tables[]"
hclose
But this does not seem to work. When I run q abc.q
on the command line it does not show the tables.
In a q process I set the port to 5001
and create some tables:
q)\p 5001
q)t1:([] a:1 2 3)
q)t2:([] a:1 2 3)
q)tables[]
`s#`t1`t2
abc.q
contains:
h:hopen `:localhost:5001
h"tables[]"
hclose h
exit 0
Then running q abc.q
I see:
KDB+ 4.0 2022.10.26 Copyright (C) 1993-2022 Kx Systems
w64/ 8(24)core 16225MB *** spectre *** EXPIRE *** *** KOD #***
`s#`t1`t2