2

I have a serverless project, I'm trying to export Dynamo DB tables into single csv, and then upload it to S3.

All npm modules i checked export single table. Is there a way to export multiple table data into one single csv?

Anbazhagan p
  • 943
  • 1
  • 14
  • 27

2 Answers2

5

To export as a CSV, adding onto @dixon1e post, use jq in the shell. With DynamoDb run:

aws dynamodb scan --table-name my-table --select ALL_ATTRIBUTES --page-size 500 --max-items 100000 --output json | jq -r '.Items' | jq -r '(.[0] | keys_unsorted) as $keys | $keys, map([.[ $keys[] ].S])[] | @csv' > export.my-table.csv
ronchu
  • 271
  • 3
  • 3
2

The AWS CLI can be used to download data from Dynamo DB:

aws dynamodb scan --table-name my-table --select ALL_ATTRIBUTES --page-size 500 --max-items 100000

The --page-size is important, there is a limit of 1M (megabyte) for every query result.

dixon1e
  • 146
  • 1
  • 7
  • 1
    It scans the table and returns a DynamoDB DSL style objects in JSON format. To make this a CSV you'll need more work around this – syberkitten Sep 24 '19 at 08:16