Last active
May 28, 2020 19:51
-
-
Save mholmes-hs/3f02309162f4f05c62c8b16fbbacfa54 to your computer and use it in GitHub Desktop.
Create a basic table on DynamoDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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