Programster's Blog

Tutorials focusing on Linux, programming, and open-source

RethinkDB - Import Data

Before you can import data into the database, you need to have the python driver. This can easily be installed through pip, pythons package manager.

Install pip if you haven't got it already.

sudo apt-get install python-pip -y

Install the driver through pip.

sudo pip install rethinkdb

Now you can import your data. To import a JSON file, execute something like below:

rethinkdb import -f input.json \
--format json \
--table test.accidents \
--pkey "Accident_Index"

RethinkDB also supports importing csv files.

rethinkdb import -f input.csv \
--format csv \
--table test.accidents \
--pkey "Accident_Index"
  • If the first line in a CSV file does not have the headers, then you need to specify --no-header
  • The primary key (--pkey) option is optional.
  • You can specify --custom-header for a custom header.
  • If you aren't using a comma for a delimiter, you can specify a custom one with --delimiter.

More information about the various import options can be found here.

Last updated: 16th August 2018
First published: 16th August 2018