import_table

DynamoDB.Client.import_table(**kwargs)

Imports table data from an S3 bucket.

See also: AWS API Documentation

Request Syntax

response = client.import_table(
    ClientToken='string',
    S3BucketSource={
        'S3BucketOwner': 'string',
        'S3Bucket': 'string',
        'S3KeyPrefix': 'string'
    },
    InputFormat='DYNAMODB_JSON'|'ION'|'CSV',
    InputFormatOptions={
        'Csv': {
            'Delimiter': 'string',
            'HeaderList': [
                'string',
            ]
        }
    },
    InputCompressionType='GZIP'|'ZSTD'|'NONE',
    TableCreationParameters={
        'TableName': 'string',
        'AttributeDefinitions': [
            {
                'AttributeName': 'string',
                'AttributeType': 'S'|'N'|'B'
            },
        ],
        'KeySchema': [
            {
                'AttributeName': 'string',
                'KeyType': 'HASH'|'RANGE'
            },
        ],
        'BillingMode': 'PROVISIONED'|'PAY_PER_REQUEST',
        'ProvisionedThroughput': {
            'ReadCapacityUnits': 123,
            'WriteCapacityUnits': 123
        },
        'SSESpecification': {
            'Enabled': True|False,
            'SSEType': 'AES256'|'KMS',
            'KMSMasterKeyId': 'string'
        },
        'GlobalSecondaryIndexes': [
            {
                'IndexName': 'string',
                'KeySchema': [
                    {
                        'AttributeName': 'string',
                        'KeyType': 'HASH'|'RANGE'
                    },
                ],
                'Projection': {
                    'ProjectionType': 'ALL'|'KEYS_ONLY'|'INCLUDE',
                    'NonKeyAttributes': [
                        'string',
                    ]
                },
                'ProvisionedThroughput': {
                    'ReadCapacityUnits': 123,
                    'WriteCapacityUnits': 123
                }
            },
        ]
    }
)
Parameters
  • ClientToken (string) --

    Providing a ClientToken makes the call to ImportTableInput idempotent, meaning that multiple identical calls have the same effect as one single call.

    A client token is valid for 8 hours after the first request that uses it is completed. After 8 hours, any request with the same client token is treated as a new request. Do not resubmit the same request with the same client token for more than 8 hours, or the result might not be idempotent.

    If you submit a request with the same client token but a change in other parameters within the 8-hour idempotency window, DynamoDB returns an IdempotentParameterMismatch exception.

    This field is autopopulated if not provided.

  • S3BucketSource (dict) --

    [REQUIRED]

    The S3 bucket that provides the source for the import.

    • S3BucketOwner (string) --

      The account number of the S3 bucket that is being imported from. If the bucket is owned by the requester this is optional.

    • S3Bucket (string) -- [REQUIRED]

      The S3 bucket that is being imported from.

    • S3KeyPrefix (string) --

      The key prefix shared by all S3 Objects that are being imported.

  • InputFormat (string) --

    [REQUIRED]

    The format of the source data. Valid values for ImportFormat are CSV , DYNAMODB_JSON or ION .

  • InputFormatOptions (dict) --

    Additional properties that specify how the input is formatted,

    • Csv (dict) --

      The options for imported source files in CSV format. The values are Delimiter and HeaderList.

      • Delimiter (string) --

        The delimiter used for separating items in the CSV file being imported.

      • HeaderList (list) --

        List of the headers used to specify a common header for all source CSV files being imported. If this field is specified then the first line of each CSV file is treated as data instead of the header. If this field is not specified the the first line of each CSV file is treated as the header.

        • (string) --
  • InputCompressionType (string) -- Type of compression to be used on the input coming from the imported table.
  • TableCreationParameters (dict) --

    [REQUIRED]

    Parameters for the table to import the data into.

    • TableName (string) -- [REQUIRED]

      The name of the table created as part of the import operation.

    • AttributeDefinitions (list) -- [REQUIRED]

      The attributes of the table created as part of the import operation.

      • (dict) --

        Represents an attribute for describing the key schema for the table and indexes.

        • AttributeName (string) -- [REQUIRED]

          A name for the attribute.

        • AttributeType (string) -- [REQUIRED]

          The data type for the attribute, where:

          • S - the attribute is of type String
          • N - the attribute is of type Number
          • B - the attribute is of type Binary
    • KeySchema (list) -- [REQUIRED]

      The primary key and option sort key of the table created as part of the import operation.

      • (dict) --

        Represents a single element of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.

        A KeySchemaElement represents exactly one attribute of the primary key. For example, a simple primary key would be represented by one KeySchemaElement (for the partition key). A composite primary key would require one KeySchemaElement for the partition key, and another KeySchemaElement for the sort key.

        A KeySchemaElement must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.

        • AttributeName (string) -- [REQUIRED]

          The name of a key attribute.

        • KeyType (string) -- [REQUIRED]

          The role that this key attribute will assume:

          • HASH - partition key
          • RANGE - sort key

          Note

          The partition key of an item is also known as its hash attribute . The term "hash attribute" derives from DynamoDB's usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.

          The sort key of an item is also known as its range attribute . The term "range attribute" derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.

    • BillingMode (string) --

      The billing mode for provisioning the table created as part of the import operation.

    • ProvisionedThroughput (dict) --

      Represents the provisioned throughput settings for a specified table or index. The settings can be modified using the UpdateTable operation.

      For current minimum and maximum provisioned throughput values, see Service, Account, and Table Quotas in the Amazon DynamoDB Developer Guide .

      • ReadCapacityUnits (integer) -- [REQUIRED]

        The maximum number of strongly consistent reads consumed per second before DynamoDB returns a ThrottlingException . For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide .

        If read/write capacity mode is PAY_PER_REQUEST the value is set to 0.

      • WriteCapacityUnits (integer) -- [REQUIRED]

        The maximum number of writes consumed per second before DynamoDB returns a ThrottlingException . For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide .

        If read/write capacity mode is PAY_PER_REQUEST the value is set to 0.

    • SSESpecification (dict) --

      Represents the settings used to enable server-side encryption.

      • Enabled (boolean) --

        Indicates whether server-side encryption is done using an Amazon Web Services managed key or an Amazon Web Services owned key. If enabled (true), server-side encryption type is set to KMS and an Amazon Web Services managed key is used (KMS charges apply). If disabled (false) or not specified, server-side encryption is set to Amazon Web Services owned key.

      • SSEType (string) --

        Server-side encryption type. The only supported value is:

        • KMS - Server-side encryption that uses Key Management Service. The key is stored in your account and is managed by KMS (KMS charges apply).
      • KMSMasterKeyId (string) --

        The KMS key that should be used for the KMS encryption. To specify a key, use its key ID, Amazon Resource Name (ARN), alias name, or alias ARN. Note that you should only provide this parameter if the key is different from the default DynamoDB key alias/aws/dynamodb .

    • GlobalSecondaryIndexes (list) --

      The Global Secondary Indexes (GSI) of the table to be created as part of the import operation.

      • (dict) --

        Represents the properties of a global secondary index.

        • IndexName (string) -- [REQUIRED]

          The name of the global secondary index. The name must be unique among all other indexes on this table.

        • KeySchema (list) -- [REQUIRED]

          The complete key schema for a global secondary index, which consists of one or more pairs of attribute names and key types:

          • HASH - partition key
          • RANGE - sort key

          Note

          The partition key of an item is also known as its hash attribute . The term "hash attribute" derives from DynamoDB's usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.

          The sort key of an item is also known as its range attribute . The term "range attribute" derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.

          • (dict) --

            Represents a single element of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.

            A KeySchemaElement represents exactly one attribute of the primary key. For example, a simple primary key would be represented by one KeySchemaElement (for the partition key). A composite primary key would require one KeySchemaElement for the partition key, and another KeySchemaElement for the sort key.

            A KeySchemaElement must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.

            • AttributeName (string) -- [REQUIRED]

              The name of a key attribute.

            • KeyType (string) -- [REQUIRED]

              The role that this key attribute will assume:

              • HASH - partition key
              • RANGE - sort key

              Note

              The partition key of an item is also known as its hash attribute . The term "hash attribute" derives from DynamoDB's usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.

              The sort key of an item is also known as its range attribute . The term "range attribute" derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.

        • Projection (dict) -- [REQUIRED]

          Represents attributes that are copied (projected) from the table into the global secondary index. These are in addition to the primary key attributes and index key attributes, which are automatically projected.

          • ProjectionType (string) --

            The set of attributes that are projected into the index:

            • KEYS_ONLY - Only the index and primary keys are projected into the index.
            • INCLUDE - In addition to the attributes described in KEYS_ONLY , the secondary index will include other non-key attributes that you specify.
            • ALL - All of the table attributes are projected into the index.
          • NonKeyAttributes (list) --

            Represents the non-key attribute names which will be projected into the index.

            For local secondary indexes, the total count of NonKeyAttributes summed across all of the local secondary indexes, must not exceed 100. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.

            • (string) --
        • ProvisionedThroughput (dict) --

          Represents the provisioned throughput settings for the specified global secondary index.

          For current minimum and maximum provisioned throughput values, see Service, Account, and Table Quotas in the Amazon DynamoDB Developer Guide .

          • ReadCapacityUnits (integer) -- [REQUIRED]

            The maximum number of strongly consistent reads consumed per second before DynamoDB returns a ThrottlingException . For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide .

            If read/write capacity mode is PAY_PER_REQUEST the value is set to 0.

          • WriteCapacityUnits (integer) -- [REQUIRED]

            The maximum number of writes consumed per second before DynamoDB returns a ThrottlingException . For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide .

            If read/write capacity mode is PAY_PER_REQUEST the value is set to 0.

Return type

dict

Returns

Response Syntax

{
    'ImportTableDescription': {
        'ImportArn': 'string',
        'ImportStatus': 'IN_PROGRESS'|'COMPLETED'|'CANCELLING'|'CANCELLED'|'FAILED',
        'TableArn': 'string',
        'TableId': 'string',
        'ClientToken': 'string',
        'S3BucketSource': {
            'S3BucketOwner': 'string',
            'S3Bucket': 'string',
            'S3KeyPrefix': 'string'
        },
        'ErrorCount': 123,
        'CloudWatchLogGroupArn': 'string',
        'InputFormat': 'DYNAMODB_JSON'|'ION'|'CSV',
        'InputFormatOptions': {
            'Csv': {
                'Delimiter': 'string',
                'HeaderList': [
                    'string',
                ]
            }
        },
        'InputCompressionType': 'GZIP'|'ZSTD'|'NONE',
        'TableCreationParameters': {
            'TableName': 'string',
            'AttributeDefinitions': [
                {
                    'AttributeName': 'string',
                    'AttributeType': 'S'|'N'|'B'
                },
            ],
            'KeySchema': [
                {
                    'AttributeName': 'string',
                    'KeyType': 'HASH'|'RANGE'
                },
            ],
            'BillingMode': 'PROVISIONED'|'PAY_PER_REQUEST',
            'ProvisionedThroughput': {
                'ReadCapacityUnits': 123,
                'WriteCapacityUnits': 123
            },
            'SSESpecification': {
                'Enabled': True|False,
                'SSEType': 'AES256'|'KMS',
                'KMSMasterKeyId': 'string'
            },
            'GlobalSecondaryIndexes': [
                {
                    'IndexName': 'string',
                    'KeySchema': [
                        {
                            'AttributeName': 'string',
                            'KeyType': 'HASH'|'RANGE'
                        },
                    ],
                    'Projection': {
                        'ProjectionType': 'ALL'|'KEYS_ONLY'|'INCLUDE',
                        'NonKeyAttributes': [
                            'string',
                        ]
                    },
                    'ProvisionedThroughput': {
                        'ReadCapacityUnits': 123,
                        'WriteCapacityUnits': 123
                    }
                },
            ]
        },
        'StartTime': datetime(2015, 1, 1),
        'EndTime': datetime(2015, 1, 1),
        'ProcessedSizeBytes': 123,
        'ProcessedItemCount': 123,
        'ImportedItemCount': 123,
        'FailureCode': 'string',
        'FailureMessage': 'string'
    }
}

Response Structure

  • (dict) --

    • ImportTableDescription (dict) --

      Represents the properties of the table created for the import, and parameters of the import. The import parameters include import status, how many items were processed, and how many errors were encountered.

      • ImportArn (string) --

        The Amazon Resource Number (ARN) corresponding to the import request.

      • ImportStatus (string) --

        The status of the import.

      • TableArn (string) --

        The Amazon Resource Number (ARN) of the table being imported into.

      • TableId (string) --

        The table id corresponding to the table created by import table process.

      • ClientToken (string) --

        The client token that was provided for the import task. Reusing the client token on retry makes a call to ImportTable idempotent.

      • S3BucketSource (dict) --

        Values for the S3 bucket the source file is imported from. Includes bucket name (required), key prefix (optional) and bucket account owner ID (optional).

        • S3BucketOwner (string) --

          The account number of the S3 bucket that is being imported from. If the bucket is owned by the requester this is optional.

        • S3Bucket (string) --

          The S3 bucket that is being imported from.

        • S3KeyPrefix (string) --

          The key prefix shared by all S3 Objects that are being imported.

      • ErrorCount (integer) --

        The number of errors occurred on importing the source file into the target table.

      • CloudWatchLogGroupArn (string) --

        The Amazon Resource Number (ARN) of the Cloudwatch Log Group associated with the target table.

      • InputFormat (string) --

        The format of the source data going into the target table.

      • InputFormatOptions (dict) --

        The format options for the data that was imported into the target table. There is one value, CsvOption.

        • Csv (dict) --

          The options for imported source files in CSV format. The values are Delimiter and HeaderList.

          • Delimiter (string) --

            The delimiter used for separating items in the CSV file being imported.

          • HeaderList (list) --

            List of the headers used to specify a common header for all source CSV files being imported. If this field is specified then the first line of each CSV file is treated as data instead of the header. If this field is not specified the the first line of each CSV file is treated as the header.

            • (string) --
      • InputCompressionType (string) --

        The compression options for the data that has been imported into the target table. The values are NONE, GZIP, or ZSTD.

      • TableCreationParameters (dict) --

        The parameters for the new table that is being imported into.

        • TableName (string) --

          The name of the table created as part of the import operation.

        • AttributeDefinitions (list) --

          The attributes of the table created as part of the import operation.

          • (dict) --

            Represents an attribute for describing the key schema for the table and indexes.

            • AttributeName (string) --

              A name for the attribute.

            • AttributeType (string) --

              The data type for the attribute, where:

              • S - the attribute is of type String
              • N - the attribute is of type Number
              • B - the attribute is of type Binary
        • KeySchema (list) --

          The primary key and option sort key of the table created as part of the import operation.

          • (dict) --

            Represents a single element of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.

            A KeySchemaElement represents exactly one attribute of the primary key. For example, a simple primary key would be represented by one KeySchemaElement (for the partition key). A composite primary key would require one KeySchemaElement for the partition key, and another KeySchemaElement for the sort key.

            A KeySchemaElement must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.

            • AttributeName (string) --

              The name of a key attribute.

            • KeyType (string) --

              The role that this key attribute will assume:

              • HASH - partition key
              • RANGE - sort key

              Note

              The partition key of an item is also known as its hash attribute . The term "hash attribute" derives from DynamoDB's usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.

              The sort key of an item is also known as its range attribute . The term "range attribute" derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.

        • BillingMode (string) --

          The billing mode for provisioning the table created as part of the import operation.

        • ProvisionedThroughput (dict) --

          Represents the provisioned throughput settings for a specified table or index. The settings can be modified using the UpdateTable operation.

          For current minimum and maximum provisioned throughput values, see Service, Account, and Table Quotas in the Amazon DynamoDB Developer Guide .

          • ReadCapacityUnits (integer) --

            The maximum number of strongly consistent reads consumed per second before DynamoDB returns a ThrottlingException . For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide .

            If read/write capacity mode is PAY_PER_REQUEST the value is set to 0.

          • WriteCapacityUnits (integer) --

            The maximum number of writes consumed per second before DynamoDB returns a ThrottlingException . For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide .

            If read/write capacity mode is PAY_PER_REQUEST the value is set to 0.

        • SSESpecification (dict) --

          Represents the settings used to enable server-side encryption.

          • Enabled (boolean) --

            Indicates whether server-side encryption is done using an Amazon Web Services managed key or an Amazon Web Services owned key. If enabled (true), server-side encryption type is set to KMS and an Amazon Web Services managed key is used (KMS charges apply). If disabled (false) or not specified, server-side encryption is set to Amazon Web Services owned key.

          • SSEType (string) --

            Server-side encryption type. The only supported value is:

            • KMS - Server-side encryption that uses Key Management Service. The key is stored in your account and is managed by KMS (KMS charges apply).
          • KMSMasterKeyId (string) --

            The KMS key that should be used for the KMS encryption. To specify a key, use its key ID, Amazon Resource Name (ARN), alias name, or alias ARN. Note that you should only provide this parameter if the key is different from the default DynamoDB key alias/aws/dynamodb .

        • GlobalSecondaryIndexes (list) --

          The Global Secondary Indexes (GSI) of the table to be created as part of the import operation.

          • (dict) --

            Represents the properties of a global secondary index.

            • IndexName (string) --

              The name of the global secondary index. The name must be unique among all other indexes on this table.

            • KeySchema (list) --

              The complete key schema for a global secondary index, which consists of one or more pairs of attribute names and key types:

              • HASH - partition key
              • RANGE - sort key

              Note

              The partition key of an item is also known as its hash attribute . The term "hash attribute" derives from DynamoDB's usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.

              The sort key of an item is also known as its range attribute . The term "range attribute" derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.

              • (dict) --

                Represents a single element of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.

                A KeySchemaElement represents exactly one attribute of the primary key. For example, a simple primary key would be represented by one KeySchemaElement (for the partition key). A composite primary key would require one KeySchemaElement for the partition key, and another KeySchemaElement for the sort key.

                A KeySchemaElement must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.

                • AttributeName (string) --

                  The name of a key attribute.

                • KeyType (string) --

                  The role that this key attribute will assume:

                  • HASH - partition key
                  • RANGE - sort key

                  Note

                  The partition key of an item is also known as its hash attribute . The term "hash attribute" derives from DynamoDB's usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.

                  The sort key of an item is also known as its range attribute . The term "range attribute" derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.

            • Projection (dict) --

              Represents attributes that are copied (projected) from the table into the global secondary index. These are in addition to the primary key attributes and index key attributes, which are automatically projected.

              • ProjectionType (string) --

                The set of attributes that are projected into the index:

                • KEYS_ONLY - Only the index and primary keys are projected into the index.
                • INCLUDE - In addition to the attributes described in KEYS_ONLY , the secondary index will include other non-key attributes that you specify.
                • ALL - All of the table attributes are projected into the index.
              • NonKeyAttributes (list) --

                Represents the non-key attribute names which will be projected into the index.

                For local secondary indexes, the total count of NonKeyAttributes summed across all of the local secondary indexes, must not exceed 100. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.

                • (string) --
            • ProvisionedThroughput (dict) --

              Represents the provisioned throughput settings for the specified global secondary index.

              For current minimum and maximum provisioned throughput values, see Service, Account, and Table Quotas in the Amazon DynamoDB Developer Guide .

              • ReadCapacityUnits (integer) --

                The maximum number of strongly consistent reads consumed per second before DynamoDB returns a ThrottlingException . For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide .

                If read/write capacity mode is PAY_PER_REQUEST the value is set to 0.

              • WriteCapacityUnits (integer) --

                The maximum number of writes consumed per second before DynamoDB returns a ThrottlingException . For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide .

                If read/write capacity mode is PAY_PER_REQUEST the value is set to 0.

      • StartTime (datetime) --

        The time when this import task started.

      • EndTime (datetime) --

        The time at which the creation of the table associated with this import task completed.

      • ProcessedSizeBytes (integer) --

        The total size of data processed from the source file, in Bytes.

      • ProcessedItemCount (integer) --

        The total number of items processed from the source file.

      • ImportedItemCount (integer) --

        The number of items successfully imported into the new table.

      • FailureCode (string) --

        The error code corresponding to the failure that the import job ran into during execution.

      • FailureMessage (string) --

        The error message corresponding to the failure that the import job ran into during execution.

Exceptions

  • DynamoDB.Client.exceptions.ResourceInUseException
  • DynamoDB.Client.exceptions.LimitExceededException
  • DynamoDB.Client.exceptions.ImportConflictException