使用变量将数据库路径传递给 \l 或 .Ql

发布于 2024-11-18 04:07:24 字数 435 浏览 8 评论 0原文

我正在编写 aq 脚本,该脚本在特定路径中加载数据库并对其进行一些处理。数据库的位置当前在脚本中硬编码,但我想将数据库路径作为参数传递,并让它从变量中的路径加载。

目前它看起来像这样:

q) \l /path/to/dbDir        #Works

我发现 .Ql 应该让我们使用变量来做到这一点,所以我尝试在脚本中使用以下内容,

dbPath:`$.z.x 0
.Q.l hsym dbPath            #Fails

当使用参数 /path/to/dbDir 运行时,脚本总是失败并出现一些不可读的内容以及:

':/path/to/dbDir: No such file or directory

有人可以帮忙吗?

I'm writing a q script that loads a db in a particular path and does some processing on it. The location of the db is currently hardcoded in the script, but I want to pass the db path as an argument and get it to load from the path in the variable.

Currently it looks like this:

q) \l /path/to/dbDir        #Works

I figured out that .Q.l should let us do this using a variable, so I tried using the following in the script,

dbPath:`$.z.x 0
.Q.l hsym dbPath            #Fails

When running with argument /path/to/dbDir, the script always fails with some unreadable stuff and:

':/path/to/dbDir: No such file or directory

Could someone please help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

冷血 2024-11-25 04:07:24

\x ... 始终等同于 system"x ...",这是“如何将变量传递给 ”的一般解决方案 命令问题

\在你的情况下的

system"l ",.z.x 0

,你想要(顺便说一句,我不认为 .Ql 涉及代码的 \l ,只涉及数据,所以不要尝试使用它来加载额外的 .q 文件)

\x ... is always equivalent to system"x ...", which is the general solution to the "how do i pass a variable to a \ command question

in your case, you want

system"l ",.z.x 0

(btw, i don't think .Q.l is involved in \l of code, only of data, so don't try to use it to load extra .q files)

注定孤独终老 2024-11-25 04:07:24

.Ql\l 只接受一个参数,它不是 hsym,而是文件或目录 姓名。

顺便说一句,不可读的东西是函数定义,后面跟着一个类型错误(因为它不期望一个 hsym)

.Q.l is synonymous with \l which only takes a single argument, which is not an hsym but a file or directory name.

Incidentally the unreadable stuff was the function definition, followed by a type error (as it was not expecting an hsym)

情魔剑神 2024-11-25 04:07:24

好的,当我们尝试不使用 hsym 的 .Ql 时,它似乎可以工作,如下所示:

dbPath:`$.z.x 0
.Q.l dbPath

Okay, it seems to work when we try .Q.l without the hsym like this:

dbPath:`$.z.x 0
.Q.l dbPath
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文