-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
374 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
[[_db]] | ||
= Databases | ||
|
||
{project-title} includes two commands for interaction with relational databases: | ||
|
||
* <<_db_import, `db-import`>>: Import database tables into Redis | ||
* <<_db_export, `db-export`>>: Export Redis data structures to a database | ||
|
||
[[_db_drivers]] | ||
== Drivers | ||
|
||
{project-title} relies on JDBC to interact with databases. | ||
It includes JDBC drivers for the most common database systems: | ||
|
||
* {link_jdbc_oracle} | ||
+ | ||
`jdbc:oracle:thin:@myhost:1521:orcl` | ||
|
||
* {link_jdbc_mssql} | ||
+ | ||
`jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]` | ||
|
||
* {link_jdbc_mysql} | ||
+ | ||
`jdbc:mysql://[host]:[port][/database][?properties]` | ||
|
||
* {link_jdbc_postgres} | ||
+ | ||
`jdbc:postgresql://host:port/database` | ||
|
||
[TIP] | ||
==== | ||
For non-included databases you must install the corresponding JDBC driver under the `lib` directory and modify the `CLASSPATH`: | ||
* *nix: `bin/riot` -> `CLASSPATH=$APP_HOME/lib/myjdbc.jar:$APP_HOME/lib/...` | ||
* Windows: `bin\riot.bat` -> `set CLASSPATH=%APP_HOME%\lib\myjdbc.jar;%APP_HOME%\lib\...` | ||
==== | ||
|
||
[[_db_import]] | ||
== Database Import | ||
|
||
The `db-import` command imports data from a relational database into Redis. | ||
|
||
NOTE: Ensure {project-title} has the relevant JDBC driver for your database. | ||
See the <<_db_drivers,Drivers>> section for more details. | ||
|
||
[source,console] | ||
---- | ||
riot db-import -h <redis host> -p <redis port> --url <jdbc url> SQL [REDIS COMMAND...] | ||
---- | ||
|
||
To show the full usage, run: | ||
|
||
[source,console] | ||
---- | ||
riot db-import --help | ||
---- | ||
|
||
You must specify at least one Redis command as a target. | ||
|
||
[IMPORTANT] | ||
==== | ||
Redis connection options apply to the root command (`riot`) and not to subcommands. | ||
In this example the Redis options will not be taken into account: | ||
[source,subs="verbatim,attributes"] | ||
---- | ||
riot db-import "SELECT * FROM customers" hset -h myredis.com -p 6380 | ||
---- | ||
==== | ||
|
||
|
||
The keys that will be written are constructed from input records by concatenating the keyspace prefix and key fields. | ||
|
||
image::mapping.svg[] | ||
|
||
.PostgreSQL Import Example | ||
[source,console] | ||
---- | ||
include::{testdir}/db-import-postgresql[] | ||
---- | ||
|
||
.Import from PostgreSQL to JSON strings | ||
[source,console] | ||
---- | ||
include::{testdir}/db-import-postgresql-set[] | ||
---- | ||
|
||
This will produce Redis strings that look like this: | ||
[source,json] | ||
---- | ||
include::{includedir}/../resources/order.json[] | ||
---- | ||
|
||
[[_db_export]] | ||
== Database Export | ||
|
||
Use the `db-export` command to read from a Redis database and writes to a SQL database. | ||
|
||
NOTE: Ensure {project-title} has the relevant JDBC driver for your database. | ||
See the <<_db_drivers,Drivers>> section for more details. | ||
|
||
The general usage is: | ||
[source,console] | ||
---- | ||
riot db-export -h <redis host> -p <redis port> --url <jdbc url> SQL | ||
---- | ||
|
||
To show the full usage, run: | ||
[source,console] | ||
---- | ||
riot db-export --help | ||
---- | ||
|
||
.Example: export to PostgreSQL | ||
[source,console] | ||
---- | ||
include::{testdir}/db-export-postgresql[] | ||
---- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,124 @@ | ||
[[_datagen]] | ||
= Data Generators | ||
= Data Generation | ||
|
||
{project-title} includes 2 commands for data generation. | ||
{project-title} includes 2 commands for data generation: | ||
|
||
* <<_datagen_struct,`generate`>>: Generate Redis data structures | ||
* <<_datagen_faker,`faker`>>: Import data from {link_datafaker} | ||
|
||
[[_datagen_struct]] | ||
== Data Structure Generator | ||
|
||
The `generate` command generates Redis data structures as well as JSON and Timeseries. | ||
|
||
[source,console] | ||
---- | ||
riot generate [OPTIONS] | ||
---- | ||
|
||
.Example | ||
[source,console] | ||
---- | ||
include::{testdir}/generate[] | ||
---- | ||
|
||
[[_datagen_faker]] | ||
== Faker Generator | ||
|
||
The `faker` command generates data using {link_datafaker}. | ||
|
||
[source,console] | ||
---- | ||
riot faker [OPTIONS] EXPRESSION... [REDIS COMMAND...] | ||
---- | ||
|
||
where `EXPRESSION` is a {link_spel} field in the form `field="expression"`. | ||
|
||
To show the full usage, run: | ||
|
||
[source,console] | ||
---- | ||
riot faker --help | ||
---- | ||
|
||
You must specify at least one Redis command as a target. | ||
|
||
[IMPORTANT] | ||
==== | ||
Redis connection options apply to the root command (`riot`) and not to subcommands. | ||
In this example the Redis options will not be taken into account: | ||
[source,subs="verbatim,attributes"] | ||
---- | ||
riot faker id="index" hset -h myredis.com -p 6380 | ||
---- | ||
==== | ||
|
||
[[_datagen_faker_keys]] | ||
=== Keys | ||
|
||
Keys are constructed from input records by concatenating the keyspace prefix and key fields. | ||
|
||
image::mapping.svg[] | ||
|
||
.Import into hashes | ||
[source,console] | ||
---- | ||
include::{testdir}/faker-hset[] | ||
---- | ||
|
||
.Import into sets | ||
[source,console] | ||
---- | ||
include::{testdir}/faker-sadd[] | ||
---- | ||
|
||
[[_datagen_faker_providers]] | ||
=== Data Providers | ||
|
||
Faker offers many data providers. | ||
Most providers don't take any arguments and can be called directly: | ||
|
||
.Simple Faker example | ||
[source,console] | ||
---- | ||
riot faker firstName="name.firstName" | ||
---- | ||
|
||
Some providers take parameters: | ||
|
||
.Parameter Faker example | ||
[source,console] | ||
---- | ||
riot faker lease="number.digits(2)" | ||
---- | ||
|
||
Refer to {link_datafaker_doc} for complete documentation. | ||
|
||
[[_datagen_faker_fields]] | ||
=== Built-in Fields | ||
|
||
In addition to the Faker fields specified with `field="expression"` you can use these built-in fields: | ||
|
||
`index`:: current iteration number. | ||
|
||
`thread`:: current thread id. | ||
Useful for multithreaded data generation. | ||
|
||
.Multithreaded data generator | ||
[source,console] | ||
---- | ||
include::{testdir}/faker-threads[] | ||
---- | ||
|
||
[[_datagen_faker_search]] | ||
=== Redis Search | ||
|
||
You can infer Faker fields from a Redis Search index using the `--infer` option: | ||
|
||
[source,console] | ||
---- | ||
include::{testdir}/faker-infer[] | ||
---- | ||
|
||
include::{includedir}/faker.adoc[leveloffset=+1] | ||
include::{includedir}/generate.adoc[leveloffset=+1] |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.