S3Dict - Access S3 buckets as dictionaries
Install
pip install s3dict
Usage
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']
Why oh why?
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.
Limitations
- Buckets are not ordered like Python dictionaries are ordered (by insertion order).
len(bucket)runs O(N) - it lists bucket objects and counts.popitem()returns an arbitrary item (since unordered).keys()andvalues()are iterators, not views.- Dictionary keys must be
str. They cannot be too long (underlying S3 key may not be >1024 chars). - Dictionary values must be serializable (Pickle by default, you can bring your own serialization / "codec").
Contributions
They are welcome. TODOs offers some ideas.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
s3dict-0.1.0.tar.gz
(3.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file s3dict-0.1.0.tar.gz.
File metadata
- Download URL: s3dict-0.1.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6c80744a77ed837884e14cefbb173f1e8994c5051b03af918c28642f8e1bb4d
|
|
| MD5 |
ca9c740338d77259724e15993a1d8bbc
|
|
| BLAKE2b-256 |
3678ee784674157b058df927f2cff9f26708af7dfe424c13c7f0d4e26b0d1224
|
File details
Details for the file s3dict-0.1.0-py3-none-any.whl.
File metadata
- Download URL: s3dict-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c5eb8aa670cfe6450f6c6b65836b9549c7a382997687c3b387eb056d60a9cca
|
|
| MD5 |
833684de85e7aae1f81b2d24666636b6
|
|
| BLAKE2b-256 |
511db8d24a77d8efeb36bb33d3191b2e847a551d10612cd53bb2d95c12e616cb
|