Dynamo db export to csv

大兔子大兔子 提交于 2021-02-10 14:24:23

问题


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?


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/49054868/dynamo-db-export-to-csv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!