Reputation: 1
I am pretty new with DynamoDB, I was trying to create a table with boto3 and find the following code:
from __future__ import print_function # Python 2/3 compatibility
import boto3
dynamodb = boto3.resource('dynamodb', region_name='us-west-2', endpoint_url="http://localhost:8000")
table = dynamodb.create_table(
TableName='Movies',
KeySchema=[
{
'AttributeName': 'year',
'KeyType': 'HASH' #Partition key
},
{
'AttributeName': 'title',
'KeyType': 'RANGE' #Sort key
}
],
AttributeDefinitions=[
{
'AttributeName': 'year',
'AttributeType': 'N'
},
{
'AttributeName': 'title',
'AttributeType': 'S'
},
],
ProvisionedThroughput={
'ReadCapacityUnits': 10,
'WriteCapacityUnits': 10
}
)
print("Table status:", table.table_status)
After running this code, I got "Table status: active". I think this means the python code works fine and table has been created. However, I couldn't see this table either from localhost Endpoint or from console. Is there anything wrong? Can anyone give me some explanations how to use python with localhost to create tables.
Thank you
Upvotes: 0
Views: 625
Reputation: 155
It's a little late, but please, check if you didn't use -inMemory instead -sharedDb
If you use the -sharedDb option, DynamoDB creates a single database file named shared-local-instance.db. Every program that connects to DynamoDB accesses this file. If you delete the file, you lose any data you have stored in it.
If you use the -inMemory option, DynamoDB doesn't write any database files at all. Instead, all data is written to memory, and the data is not saved when you terminate DynamoDB.
$ java -Djava.library.pathh=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
Upvotes: 1