-
-
Save hazdik/64dabdbcbb90c42cb8c29bc6202077c2 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 | |
def main(): | |
# 1 - Create Client | |
ddb = boto3.resource('dynamodb', | |
endpoint_url='http://localhost:8000', | |
region_name='dummy', | |
aws_access_key_id='dummy', | |
aws_secret_access_key='dummy') | |
# 2 - Create the Table | |
ddb.create_table(TableName='Transactions', | |
AttributeDefinitions=[ | |
{ | |
'AttributeName': 'TransactionId', | |
'AttributeType': 'S' | |
} | |
], | |
KeySchema=[ | |
{ | |
'AttributeName': 'TransactionId', | |
'KeyType': 'HASH' | |
} | |
], | |
ProvisionedThroughput= { | |
'ReadCapacityUnits': 10, | |
'WriteCapacityUnits': 10 | |
} | |
) | |
print('Successfully created Table') | |
table = ddb.Table('Transactions') | |
input = {'TransactionId': '9a0', 'State': 'PENDING', 'Amount': 50} | |
#3 - Insert Data | |
table.put_item(Item=input) | |
print('Successfully put item') | |
#4 - Scan Table | |
scanResponse = table.scan(TableName='Transactions') | |
items = scanResponse['Items'] | |
for item in items: | |
print(item) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment