Dynamodb - create a table

    0

    13

    AWS and boto3 recipes for Python

    Library: boto3

    Shortcut: aws.dynamodb.create_table

    import boto3
    
    # Get the service resource.
    dynamodb = boto3.resource('dynamodb')
    # Create the DynamoDB table.
    table = dynamodb.create_table(
      TableName='table',
      KeySchema=[
        {
          'AttributeName': 'attribute_name',
          'KeyType': 'HASH'
        },
        {
          'AttributeName': 'attribute_name',
          'KeyType': 'RANGE'
        }
      ],
      AttributeDefinitions=[
        {
          'AttributeName': 'attribute_name',
          'AttributeType': 'S'
        },
        {
          'AttributeName': 'attribute_name',
          'AttributeType': 'S'
        },
      ],
      ProvisionedThroughput={
        'ReadCapacityUnits': 5,
        'WriteCapacityUnits': 5
      }
    )
    # Wait until the table exists.
    table.wait_until_exists()
    # Print out some data about the table.
    print(table.item_count)
    
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.