Database Import

The db-import command imports data from a relational database into Redis.

Ensure RIOT-X has the relevant JDBC driver for your database. See the Drivers section for more details.
riotx db-import --jdbc-url <jdbc url> -u <Redis URI> SQL [REDIS COMMAND...]

To show the full usage, run:

riotx db-import --help

You must specify at least one Redis command as a target.

Redis connection options apply to the root command (riotx) and not to subcommands.

The keys that will be written are constructed from input records by concatenating the keyspace prefix and key fields.

mapping
PostgreSQL Import Example
riotx db-import "SELECT * FROM orders" \
  --jdbc-url jdbc:postgresql://localhost:5432/mydb \
  --jdbc-user myuser \
  --jdbc-pass mypass \
  hset order:#{order_id}
Import from PostgreSQL to JSON strings
riotx db-import "SELECT * FROM orders" \
  --jdbc-url jdbc:postgresql://localhost:5432/mydb \
  --jdbc-user myuser \
  --jdbc-pass mypass \
  set order:#{order_id}

This will produce Redis strings that look like this:

{"order_id":123,"customer_name":"John Doe","total":99.99,"order_date":"2024-11-06"}