Skip to content

Instantly share code, notes, and snippets.

@coffeemug
Last active January 19, 2023 08:21
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save coffeemug/5894257 to your computer and use it in GitHub Desktop.
Save coffeemug/5894257 to your computer and use it in GitHub Desktop.
Description of import and export feature introduced in RethinkDB 1.7.

You can import data as follows:

# Import a JSON document into table `users` in database `my_db`
$ rethinkdb import -c HOST:PORT -f user_data.json --table my_db.users

# Import a CSV document
$ rethinkdb import -c HOST:PORT -f user_data.csv --format csv --table my_db.users

The export command works as follows:

# Export a table into a JSON file (placed in the directory
# rethinkdb_export_DATE_TIME by default)
$ rethinkdb export -c HOST:PORT -e my_db.users

# Export a table into a CSV file
$ rethinkdb export -c HOST:PORT -e my_db.users --format csv \
                   --fields first_name,last_name,address      # `--fields` is mandatory when exporting into CSV

This is only a small taste of what import and export commands can do. Run rethinkdb import --help and rethinkdb export --help for more information on these commands.

See more about the 1.7 release in the release announcement.

@BarthesSimpson
Copy link

Getting this error when trying to import a csv:
new-line character seen in unquoted field - do you need to open the file in universal-newline mode?

export works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment