Create RethinkDB database from command line
Asked Answered
B

3

5

I need to programatically create a RethinkDB database from the command line. However...I have no clue how to do this.

I know that I can do this from the web UI or from a client driver, but isn't there a command that does this?

Brooke answered 30/4, 2015 at 21:12 Comment(0)
A
3

If you have the Python driver you can do the following:

echo -e  'import rethinkdb as r; \nr.connect("localhost", 28015).repl() \nr.db_create("NAME_OF_YOUR_DATABASE").run()'  | python

To install the Python driver, you can just use pip:

pip install rethinkdb

This might not be the best way of doing this, but it might be the easiest way of achieving this if you want to create a database in one line from the command line.

If you a Node.js developer, I would recommend using the two CLIS mglukhovsky mentioned.

Asthmatic answered 30/4, 2015 at 22:44 Comment(0)
T
4

As mlucy mentioned, you can create databases and tables using the query language. If you'd like to run RethinkDB queries directly from the command line, you may want to try one of these libraries:

Thorma answered 30/4, 2015 at 22:32 Comment(0)
A
3

If you have the Python driver you can do the following:

echo -e  'import rethinkdb as r; \nr.connect("localhost", 28015).repl() \nr.db_create("NAME_OF_YOUR_DATABASE").run()'  | python

To install the Python driver, you can just use pip:

pip install rethinkdb

This might not be the best way of doing this, but it might be the easiest way of achieving this if you want to create a database in one line from the command line.

If you a Node.js developer, I would recommend using the two CLIS mglukhovsky mentioned.

Asthmatic answered 30/4, 2015 at 22:44 Comment(0)
A
1

As of RethinkDB 2.0 I believe you can only do this with the web UI or a client driver. Is there a reason why shelling out to Python or Ruby doesn't work here?

Addieaddiego answered 30/4, 2015 at 22:23 Comment(1)
It can work, but it would look cleaner to put something like rethinkdb createdb name in a provisioning script.Brooke

© 2022 - 2024 — McMap. All rights reserved.