1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
# Boto should get credentials from ~/.aws/credentials or the environment
import asyncio
import uuid
from aiobotocore.session import get_session
async def go():
session = get_session()
async with session.create_client(
'dynamodb', region_name='us-west-2'
) as client:
# Create random table name
table_name = f'aiobotocore-{uuid.uuid4()}'
print('Requesting table creation...')
await client.create_table(
TableName=table_name,
AttributeDefinitions=[
{'AttributeName': 'testKey', 'AttributeType': 'S'},
],
KeySchema=[
{'AttributeName': 'testKey', 'KeyType': 'HASH'},
],
ProvisionedThroughput={
'ReadCapacityUnits': 10,
'WriteCapacityUnits': 10,
},
)
print("Waiting for table to be created...")
waiter = client.get_waiter('table_exists')
await waiter.wait(TableName=table_name)
print(f"Table {table_name} created")
if __name__ == '__main__':
asyncio.run(go())
|