如何使用python在dynamodb中创建按需表?

Tal*_*nse 4 ondemand python-3.x amazon-dynamodb

我尝试了这种方式,但收到错误参数 ProvisionedThroughput.ReadCapacityUnits 的类型无效,值:按需,类型:<class 'str'>,有效类型:<class 'int'>

ProvisionedThroughput={ 'ReadCapacityUnits': 'on-demand', 'WriteCapacityUnits': 'on-demand' }

ser*_*erg 5

ddb.create_table(
    TableName='my_table',
    KeySchema=[
        {'AttributeName': 'id', 'KeyType': 'HASH'},
    ],
    AttributeDefinitions=[
        {'AttributeName': 'id', 'AttributeType': 'S'},
    ],
    BillingMode='PAY_PER_REQUEST',
)
Run Code Online (Sandbox Code Playgroud)