Created
February 5, 2023 16:49
-
-
Save achad4/73b1ba8dd3cd95f0bfbe6c0256ac4a57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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