Migrate from JSON file source to Oracle NoSQL Database Cloud Service
This example shows the usage of Oracle NoSQL Database Migrator to copy data from a JSON file source to Oracle NoSQL Database Cloud Service.
After evaluating multiple options, an organization finalizes Oracle NoSQL Database Cloud Service as its NoSQL Database platform. As its source contents are in JSON file format, they are looking for a way to migrate them to Oracle NoSQL Database Cloud Service.
In this example, you will learn to migrate the data from a JSON file called SampleData.json
. You run the runMigrator
utility by passing a pre-created configuration file. If the configuration file is not provided as a run time parameter, the runMigrator
utility prompts you to generate the configuration through an interactive procedure.
- Identify the source and sink for the migration.
- Source: JSON source file.
SampleData.json
is the source file. It contains multiple JSON documents with one document per line, delimited by a new line character.{"id":6,"val_json":{"array":["q","r","s"],"date":"2023-02-04T02:38:57.520Z","nestarray":[[1,2,3],[10,20,30]],"nested":{"arrayofobjects":[{"datefield":"2023-03-04T02:38:57.520Z","numfield":30,"strfield":"foo54"},{"datefield":"2023-02-04T02:38:57.520Z","numfield":56,"strfield":"bar23"}],"nestNum":10,"nestString":"bar"},"num":1,"string":"foo"}} {"id":3,"val_json":{"array":["g","h","i"],"date":"2023-02-02T02:38:57.520Z","nestarray":[[1,2,3],[10,20,30]],"nested":{"arrayofobjects":[{"datefield":"2023-02-02T02:38:57.520Z","numfield":28,"strfield":"foo3"},{"datefield":"2023-02-02T02:38:57.520Z","numfield":38,"strfield":"bar"}],"nestNum":10,"nestString":"bar"},"num":1,"string":"foo"}} {"id":7,"val_json":{"array":["a","b","c"],"date":"2023-02-20T02:38:57.520Z","nestarray":[[1,2,3],[10,20,30]],"nested":{"arrayofobjects":[{"datefield":"2023-01-20T02:38:57.520Z","numfield":28,"strfield":"foo"},{"datefield":"2023-01-22T02:38:57.520Z","numfield":38,"strfield":"bar"}],"nestNum":10,"nestString":"bar"},"num":1,"string":"foo"}} {"id":4,"val_json":{"array":["j","k","l"],"date":"2023-02-03T02:38:57.520Z","nestarray":[[1,2,3],[10,20,30]],"nested":{"arrayofobjects":[{"datefield":"2023-02-03T02:38:57.520Z","numfield":28,"strfield":"foo"},{"datefield":"2023-02-03T02:38:57.520Z","numfield":38,"strfield":"bar"}],"nestNum":10,"nestString":"bar"},"num":1,"string":"foo"}}
- Sink: Oracle NoSQL Database Cloud Service.
- Source: JSON source file.
- Identify your OCI cloud credentials and capture them in the configuration file. Save the config file in
/home/user/.oci/config
. For more details, see Acquiring Credentials in Using Oracle NoSQL Database Cloud Service.[DEFAULT] tenancy=ocid1.tenancy.oc1.... user=ocid1.user.oc1.... fingerprint= 43:d1:.... region=us-ashburn-1 key_file=</fully/qualified/path/to/the/private/key/> pass_phrase=<passphrase>
- Identify the region endpoint and compartment name for your Oracle NoSQL Database Cloud Service.
- endpoint:
us-ashburn-1
- compartment:
Training-NoSQL
- endpoint:
- Identify the following details for the JSON source file:
-
schemaPath:
<absolute path to the schema definition file containing DDL statements for the NoSQL table at the sink>
.In this example, the DDL file isschema_json.ddl
.create table Migrate_JSON (id INTEGER, val_json JSON, PRIMARY KEY(id));
The Oracle NoSQL Database Migrator provides an option to create a table with the default schema if the
schemaPath
is not provided. For more details, see Identify the Source and Sink topic in the Workflow for Oracle NoSQL Database Migrator. - Datapath:
<absolute path to a file or directory containing the JSON data for migration>
.
-
SampleData.json
to Oracle NoSQL Database Cloud Service, perform the following:
Migrate_JSON
table is created with the source data. For the procedure to access the console, see Accessing the Service from the Infrastructure Console article in the Oracle NoSQL Database Cloud Service document.
Figure 1-1 Oracle NoSQL Database Cloud Service Console Tables
Figure 1-2 Oracle NoSQL Database Cloud Service Console Table Data