AWS SDK for Python (Boto3) 提供適用於 AWS 基礎設施服務的 Python API。
您可以使用 SDK for Python 在 Amazon S3、Amazon EC2、Amazon DynamoDB 等之上建置應用程式。
本篇文章會將會直接使用並且讓我親身經歷的技術,讓你更快的進入這個領域
Dynamodb: Aws 專用的Nosql
import boto3
class DDB():
def __init__(self, profile, test=False, throttling=records_per_second, logger=LOGGER):
self.profile = profile
self.throttling = throttling
boto3.setup_default_session(profile_name=profile)
if test:
self.resource = boto3.resource(
'dynamodb', endpoint_url='http://localhost:8000')
self.client = boto3.client(
'dynamodb', endpoint_url='http://localhost:8000')
self.auto_scaling_client = boto3.client(
'application-autoscaling', endpoint_url='http://localhost:8000')
else:
self.resource = boto3.resource('dynamodb')
self.client = boto3.client('dynamodb')
self.auto_scaling_client = boto3.client('application-autoscaling')
self.query_paginator = self.client.get_paginator('query')
self.scan_paginator = self.client.get_paginator('scan')
self.logger = logger
def table(self, table_name):
return self.resource.Table(table_name)
def create_table(self, table_name):
table =self.resource.create_table(
TableName= table_name,
# table elelment
KeySchema=[
],
)
# Wait until the table exists.
table.wait_until_exists()
I write a really simple orm in dynamodb