Skip to content

Instantly share code, notes, and snippets.

@mholmes-hs
Last active May 28, 2020 19:51
Show Gist options
  • Save mholmes-hs/3f02309162f4f05c62c8b16fbbacfa54 to your computer and use it in GitHub Desktop.
Save mholmes-hs/3f02309162f4f05c62c8b16fbbacfa54 to your computer and use it in GitHub Desktop.
Create a basic table on DynamoDB
import boto3
from boto3.dynamodb.conditions import Key
def create_table():
dynamodb = boto3.resource('dynamodb')
table = dynamodb.create_table(
TableName='Users',
KeySchema=[
{
'AttributeName': 'id',
'KeyType': 'HASH'
},
],
AttributeDefinitions=[
{
'AttributeName': 'id',
'AttributeType': 'N'
},
],
ProvisionedThroughput={
'ReadCapacityUnits': 1,
'WriteCapacityUnits': 1,
}
)
print("Table status:", table.table_status)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment