连接 kdb q 中的 hdb 数据库到 .q 脚本的方法是?

huangapple go评论45阅读模式
英文:

How to connect a hdb database in kdb q to .q script?

问题

我想在一个kdb的.q脚本中连接到一个hdb数据库,并在脚本中进行查询,而不是直接在q提示符上进行查询。

我现在在abc.q中有如下代码:

h:hopen `:url:port:userid:pwd
h"tables[]"
hclose

但似乎不起作用。当我在命令行上运行q abc.q时,它不显示表格。

英文:

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.

答案1

得分: 0

在一个q进程中,我将端口设置为5001并创建了一些表:

q)\p 5001
q)t1:([] a:1 2 3)
q)t2:([] a:1 2 3)
q)tables[]
`s#`t1`t2

abc.q 包含了以下内容:

h:hopen `:localhost:5001
h"tables[]"
hclose h
exit 0

然后运行 q abc.q,我看到:

KDB+ 4.0 2022.10.26 Copyright (C) 1993-2022 Kx Systems
w64/ 8(24)core 16225MB *** spectre *** EXPIRE *** *** KOD #***

`s#`t1`t2
英文:

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

huangapple
  • 本文由 发表于 2023年5月13日 20:36:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76242761.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定