GitHub - mkjt2/s3dict: S3Dict - Access S3 buckets as dictionaries

GitHub

1 min read Original article ↗
import boto3
import s3dict
s3dict.enable()

# create a boto3 bucket resource
bucket = boto3.resource("s3").Bucket('s3dict-test')

# S3 object with key 'hello' is created, with content 'world' (pickled)
bucket['hello'] = 'world'
bucket['hola'] = 'mundo'

for k, v in bucket.items():
    print(f'{k} -> {v}')

del bucket['hello']

Just for curiosity. bucket[k] = v is easier than bucket.put_object(Key=k, Body=pickle.dumps(v)) right? :)

Please let us know if you found a real use case.

They are welcome. TODOs offers some ideas.