Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DynamoDB loading old local database file

A while ago I loaded a bunch of JSON data into a local DynamoDB instance for practice. I did some queries and stored the data into a CSV and ended up closing my connection.

So I have this sample_data.db file on my laptop that's 7GB and need to access it again. Normally when I create a DynamoDB instance, I say:

java \
    -Djava.library.path=./DynamoDBLocal_lib \
    -jar DynamoDBLocal.jar \
    -dbPath /Users/myname/Documents/data/sample_data.db

So I did that to create the file but how do I now open another connection to that pre-existing file? Whenever I do the above, it just says:

Invalid directory for database creation.

Clearly that means the above command is only for creating a new DB - sorry if this is a trivial question but how do I open a connection to an old one?

Do I have to upload it to AWS somehow? Or is there a way?

EDIT: I was using this as a reference, but didn't see a command to specify path to a pre-existing DB. http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html

like image 402
shishy Avatar asked Apr 22 '26 03:04

shishy


1 Answers

The problem is rooted in the fact that local DynamoDB does not allow you to directly specify the database file name, only the path where the file should be stored/loaded. The file name(s) is/are derived from your AWS access key for DynamoDB local and the AWS region. Alternately, if you specify the -sharedDb option, the single database file is stored as shared-local-instance.db. The -dbPath option defines where the DynamoDB local instance should look for these database files.

In order to load your old database file, I would recommend renaming it to conform to the naming conventions (so that DynamoDB will recognize it), and specifying the -dbPath option without the filename part. Hopefully, this will allow you to access your data.

Example:

mv sample_data.db shared-local-instance.db
java \
    -Djava.library.path=./DynamodDBLocal_lib \
    -jar DynamoDBLocal.jar \
    -dbPath /Users/myname/Documents/data

Note: the database file naming is a little vaguely defined (at least, my very limited search for naming criteria didn't turn up much). You may need to play around with it a bit to figure out the exact naming that is expected.

like image 151
Liam C Avatar answered Apr 23 '26 17:04

Liam C