RethinkDB 有命令行客户端(提示符)吗?

Does RethinkDB have a command line client (a prompt)?

RethinkDB 是否有像 psql 这样的集成命令行客户端?

我看过 Web 管理控制台,但它很容易与 bash 脚本交互或从 ssh 手动操作,麻烦...

我看过:

https://github.com/stiang/recli

还有一个问题与这个问题有关:

https://github.com/rethinkdb/rethinkdb/issues/189

但是解决方案不清楚,rethinkdb repl不存在

目前,RethinkDB 没有官方 "shell" 或 "query CLI"。正如您所发现的,我们在 WebUI 中确实有数据资源管理器,它允许您使用驱动程序执行任何操作。

我通常做的,因为我的大多数机器上都有 RethinkDB 运行,我只是在我的 ipython 配置中添加了两行以在启动时加载 rethinkdb 驱动程序和连接到我的本地数据库。

这只是几个步骤:

  1. ipython profile create 创建 ~/.ipython/profile_default/ipython_config.py
  2. 在此配置文件中编辑 c.InteractiveShellApp.exec_lines(第 35 行),如下所示:

    c.InteractiveShellApp.exec_lines = [
      "import rethinkdb as r",
      "conn = r.connect()"
    ]
    
  3. 现在,当您开始时ipython,您会看到`conn 已经与RethinkDB 建立了连接。

    $ ipython3
    Python 3.5.2 (default, Jul 28 2016, 21:28:00)
    Type "copyright", "credits" or "license" for more information.
    
    IPython 5.0.0 -- An enhanced Interactive Python.
    ?         -> Introduction and overview of IPython's features.
    %quickref -> Quick reference.
    help      -> Python's own help system.
    object?   -> Details about 'object', use 'object??' for extra details.
    
    In [1]: conn
    Out[1]: <rethinkdb.net.DefaultConnection at 0x109d8c4e0>
    
    In [2]: r.db_list().run(conn)
    Out[2]:
    ['asyncio',
     'example',
     ...]
    

这使得将 ipython 变成您的 "ReQL-cli" 更加方便。