Skip to content

Instantly share code, notes, and snippets.

@mamiwinsfall93
Created January 18, 2020 16:58
Show Gist options
  • Save mamiwinsfall93/bf42c0cc4c73c754fd12957addb7efc7 to your computer and use it in GitHub Desktop.
Save mamiwinsfall93/bf42c0cc4c73c754fd12957addb7efc7 to your computer and use it in GitHub Desktop.
DynamoDB
import boto3
# Get the service resource.
dynamodb = boto3.resource('dynamodb')
# Create the DynamoDB table.
table = dynamodb.create_table(
TableName='courses',
KeySchema=[
{
'AttributeName': 'courseID',
'KeyType': 'HASH'
},
{
'AttributeName': 'Title',
'KeyType': 'RANGE'
}
],
AttributeDefinitions=[
{
'AttributeName': 'courseID',
'AttributeType': 'N'
},
{
'AttributeName': 'Title',
'AttributeType': 'S'
},
],
ProvisionedThroughput={
'ReadCapacityUnits': 5,
'WriteCapacityUnits': 5
}
)
# Wait until the table exists.
table.meta.client.get_waiter('table_exists').wait(TableName='users')
# Print out some data about the table.
print(table.item_count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment