Skip to content

Instantly share code, notes, and snippets.

@achad4
Created February 5, 2023 16:49
Show Gist options
  • Save achad4/73b1ba8dd3cd95f0bfbe6c0256ac4a57 to your computer and use it in GitHub Desktop.
Save achad4/73b1ba8dd3cd95f0bfbe6c0256ac4a57 to your computer and use it in GitHub Desktop.
import boto3
dynamodb = boto3.resource("dynamodb")
params = {
"TableName": "customer_purchase_ts",
"KeySchema": [
{"AttributeName": "customer_id", "KeyType": "HASH"}
],
"LocalSecondaryIndexes": [
{
"IndexName": "feature_time_series",
"KeySchema": [
{"AttributeName": "customer_id", "KeyType": "HASH"},
{"AttributeName": "transaction_date_epoch", "KeyType": "RANGE"}
],
"Projection": {
"ProjectionType": "ALL"
},
}
],
"GlobalSecondaryIndexes": [
{
"IndexName": "purchase_category",
"KeySchema": [
{"AttributeName": "category_name", "KeyType": "HASH"},
{"AttributeName": "customer_id", "KeyType": "RANGE"}
],
"Projection": {
"ProjectionType": "KEYS_ONLY"
},
}
],
"AttributeDefinitions": [
{"AttributeName": "customer_id", "AttributeType": "S"},
{"AttributeName": "category_name", "AttributeType": "S"},
{"AttributeName": "transaction_date_epoch", "AttributeType": "N"},
],
#Other settings...
}
}
table = dynamodb.create_table(**params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment