从命令行运行 QuestDB 查询

发布于 2025-01-20 18:20:20 字数 54 浏览 2 评论 0原文

我将数据插入QuestDB中的表中。我现在想查询表并从控制台测量其运行时。如何通过命令显示它?

I inserted a data into a table in QuestDB. I want to query now the table and measure its runtime from the console. How I can display it through command?

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

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

发布评论

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

评论(3

池予 2025-01-27 18:20:20

最简单的是通过http:// localhost:9000和查询从table_name或简单地table_name

If you want a command line option then you can run curl to 导出到CSV

curl -G --data-urlencode "query=table_name" http://localhost:9000/exp

Easiest is to connect to Web Console at http://localhost:9000 and query select * from table_name or simply table_name.

If you want a command line option then you can run curl to export to csv

curl -G --data-urlencode "query=table_name" http://localhost:9000/exp
孤云独去闲 2025-01-27 18:20:20

您始终可以使用本地主机启动网络服务器并像这样输入curl命令

curl -G --data-urlencode "query=SELECT * FROM emp" http://localhost:port/exp

You can always start a webserver using localhost and put curl command like this

curl -G --data-urlencode "query=SELECT * FROM emp" http://localhost:port/exp
征﹌骨岁月お 2025-01-27 18:20:20

您可以使用psql基于终端的前端,以便PostgreSQL通过Postgres Wire协议连接到QuestDB,该协议默认情况下在8812端口上公开。如果您已经安装了PSQL,则可以简单地连接为:

psql -Uadmin -h localhost -p 8812

或者,如果您拥有Docker,也可以运行:

docker run -it --rm --network host postgres:13.7-alpine psql -Uadmin -h localhost -p 8812

它将在容器中启动psql,然后使用主机网络连接到QUESTDB。如果您在其他Docker网络上的容器中运行QuestDB,则必须使用它。

例子:

$ docker run -d --rm -p 8812:8812 -v /tmp/questdb:/root/.questdb/db questdb/questdb:6.2.1
0a0d4372a4babecf4f6da5a2b726cd16c18667acb770e0db240ce10150f2a236

$ docker run -it --rm --network host postgres:13.7-alpine psql -Uadmin -h localhost -p 8812
Password for user admin: 
psql (13.7, server 11.3)
Type "help" for help.

admin=> \d
             List of relations
 Schema |       Name       | Type  | Owner  
--------+------------------+-------+--------
 public | telemetry        | table | public
 public | telemetry_config | table | public
(2 rows)

admin=> select * from telemetry limit 1;
          created           | event | origin 
----------------------------+-------+--------
 2022-05-25 03:50:43.852890 |   100 |      1
(1 row)

admin=> 

You can use psql terminal based front end for Postgresql to connect to QuestDB via the postgres wire protocol that is exposed on 8812 port by default. If you have psql installed already, you can simply connect as:

psql -Uadmin -h localhost -p 8812

Or if you have docker, you can also run:

docker run -it --rm --network host postgres:13.7-alpine psql -Uadmin -h localhost -p 8812

which will launch psql in a container and connect to QuestDB using the host network. If you run QuestDB in a container on a different docker network, you would have to use that instead.

Example:

$ docker run -d --rm -p 8812:8812 -v /tmp/questdb:/root/.questdb/db questdb/questdb:6.2.1
0a0d4372a4babecf4f6da5a2b726cd16c18667acb770e0db240ce10150f2a236

$ docker run -it --rm --network host postgres:13.7-alpine psql -Uadmin -h localhost -p 8812
Password for user admin: 
psql (13.7, server 11.3)
Type "help" for help.

admin=> \d
             List of relations
 Schema |       Name       | Type  | Owner  
--------+------------------+-------+--------
 public | telemetry        | table | public
 public | telemetry_config | table | public
(2 rows)

admin=> select * from telemetry limit 1;
          created           | event | origin 
----------------------------+-------+--------
 2022-05-25 03:50:43.852890 |   100 |      1
(1 row)

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