Skip to content

Commit 4097cf4

Browse files
authored
Merge pull request #160 from davetownG/Issue-137-Scripts---NoSQLWorkbench
Issue 137 scripts no sql workbench enhance README.md
2 parents 1e1ac86 + b2b43e7 commit 4097cf4

File tree

1 file changed

+70
-7
lines changed

1 file changed

+70
-7
lines changed
+70-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,76 @@
1-
# Export Amazon DynamoDB Tables to NoSQL Workbench
1+
# 🚀 Export Amazon DynamoDB Tables to NoSQL Workbench
22

3-
This directory contains a node.js script that when run, will export a table's meta data and the first 1MB worth of data into a format that can be imported into [NoSQL Workbench for Amazon DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/workbench.html).
3+
This guide will help you export the schema and first 1MB of data from an existing DynamoDB table using the script **create-workbench-import.js**. The script's JSON output can be imported into [NoSQL Workbench for Amazon DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/workbench.html) to create the table and populate the data within NoSQL Workbench.
44

5-
You will need to modify the script to add the Amazon Web Services Region you want to export. This script relies on the credentials in ~/.aws to authenticate. The command directs the json output to stdout. You should attempt to run it with a credential that has read only access to the table.
5+
## 🏃 How to Get Started
66

7-
`node create-workbench-import.js YourTableNameHere > YourTableNameHere.json`
7+
1. **Download Script**
8+
9+
Copy the `create-workbench-import.js` file to the folder you wish to run it from.
810

9-
Once you have the JSON file from your table, you can perform a "import data model" in NoSQL Workbench to bring it into the tool.
11+
2. **Install Node.js**
1012

11-
Initial script by [Rob McCauley](https://github.com/robm26).
13+
Make sure you’ve got Node.js installed on your machine.
14+
👉 [Get Node.js here](https://nodejs.org/en)
1215

13-
This script is provided as is and at your own risk. There are no guarantees expressly written or implied.
16+
3. **Install AWS SDK for JavaScript**
17+
18+
Make sure you’ve got AWS SDK for JavaScript installed on your machine.
19+
👉 [Get AWS SDK for JavaScript here](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/installing-jssdk.html)
20+
21+
4. **Modify the Region in the Script**
22+
23+
You may need to modify line 13 in the script and update the region name to the appropriate AWS Region for your existing DynamoDB table.
24+
```
25+
AWS.config.region = process.env.AWS_REGION || 'us-east-1';
26+
```
27+
6. **Credentials**
28+
29+
This script relies on the credentials in `~/.aws` to authenticate. You should run it with a credential that has read only access to the table.
30+
31+
8. **Run the Script**
32+
33+
Open a terminal, navigate to the script folder, and run the below command, replacing "YourTableNameHere" with your existing DynamoDB table name.
34+
```
35+
node create-workbench-import.js YourTableNameHere > YourTableNameHere.json
36+
```
37+
The command directs the JSON output to `YourTableNameHere.json`. You can see part of a sample JSON output for a table named 'Blog1' below.
38+
39+
```
40+
{
41+
"ModelName": "Blog1",
42+
"ModelMetadata": {
43+
"Author": "testuser",
44+
"DateCreated": "Wed Oct 23 2024 19:31:56 GMT-0700 (Pacific Daylight Time)",
45+
"DateLastModified": "Wed Oct 23 2024 19:31:56 GMT-0700 (Pacific Daylight Time)",
46+
"Description": "A NoSQL Workbench model generated from table Blog1",
47+
"AWSService": "Amazon DynamoDB",
48+
"Version": "2.0"
49+
},
50+
"DataModel": [
51+
{
52+
"TableName": "Blog1",
53+
"KeyAttributes": {
54+
"PartitionKey": {
55+
"AttributeName": "email",
56+
"AttributeType": "S"
57+
},
58+
"SortKey": {
59+
"AttributeName": "State",
60+
"AttributeType": "S"
61+
}
62+
```
63+
If you wish to direct the output to stdout instead of a file, leave off the `> YourTableNameHere.json` in the command.
64+
65+
```
66+
node create-workbench-import.js YourTableNameHere
67+
```
68+
69+
10. **Use the JSON File to Import into NoSQL Workbench**
70+
71+
Once you have the JSON file from your table, you can perform a "import data model" in NoSQL Workbench to bring it into the tool.
72+
\
73+
\
74+
Initial script by [Rob McCauley](https://github.com/robm26).
75+
76+
This script is provided as is and at your own risk. There are no guarantees expressly written or implied.

0 commit comments

Comments
 (0)