CShelve – The Python Dictionary That Lives in the Cloud 🚀
Store Python objects locally or in the cloud with the same, simple dictionary interface. CShelve lets you store and retrieve any Python object—lists, DataFrames, JSON, binary files—whether on local files, AWS S3, Azure Blob Storage, or in-memory, all with the same simple dictionary-like interface.
📌 Why CShelve?
- Familiar & Fast – If you know Python dictionaries, you already know CShelve.
- Cloud-Ready – Switch between local files and cloud storage (AWS S3, Azure Blob, SFTP) with zero code changes.
- Lightweight – No database servers, no migrations, no schema headaches and minimals dependencies.
- Flexible Formats – Store pickled Python objects by default, or any format as bytes (JSON, CSV, Parquet, images, etc.).
- Cost-Effective Scaling – Tap into cheap and durable cloud storage without maintaining infrastructure.
🔍 What’s “Shelve” Anyway?
Python’s built-in shelve module stores Python objects in a file with a dictionary-like API.
CShelve supercharges it with:
- Cloud backends
- Multiple authentication methods
- Format flexibility
- Provider-agnostic switching
If you can do:
mydict['key'] = value
You can use CShelve—locally, in the cloud, or on-premises.
📦 Installation
# Local storage only
pip install cshelve
# With AWS S3 support
pip install cshelve[aws-s3]
# With Azure Blob support
pip install cshelve[azure-blob]
⚡ Quick Start
Local Storage
import cshelve
db = cshelve.open('local.db')
db['user'] = {'name': 'Alice', 'age': 30}
print(db['user']) # {'name': 'Alice', 'age': 30}
db.close()
AWS S3
# Install provider
pip install cshelve[aws-s3]
aws-s3.ini
[default]
provider = aws-s3
bucket_name = mybucket
auth_type = access_key
key_id = $AWS_KEY_ID
key_secret = $AWS_KEY_SECRET
Python
import cshelve
db = cshelve.open('aws-s3.ini')
db['session'] = 'cloud storage is easy'
print(db['session'])
db.close()
Azure Blob
# Install provider
pip install cshelve[azure-blob]
azure-blob.ini
[default]
provider = azure-blob
account_url = https://myaccount.blob.core.windows.net
auth_type = passwordless
container_name = mycontainer
Python
import cshelve
db = cshelve.open('azure-blob.ini')
db['analytics'] = [1, 2, 3, 4]
print(db['analytics'])
db.close()
📊 Advanced Examples
Storing Pandas DataFrames in the Cloud
import cshelve, pandas as pd
df = pd.DataFrame({'name': ['Alice', 'Bob'], 'age': [25, 30]})
with cshelve.open('azure-blob.ini') as db:
db['users'] = df
with cshelve.open('azure-blob.ini') as db:
print(db['users'])
Storing JSON (no pickle)
import json, cshelve
data = {"msg": "Hello, Cloud!"}
with cshelve.open('azure-blob.ini') as db:
db['config.json'] = json.dumps(data).encode()
with cshelve.open('azure-blob.ini') as db:
print(json.loads(db['config.json'].decode()))
🛠 Supported Providers
| Provider | Install Extra | Notes |
|---|---|---|
| Local | none | Stores data in a local .db file |
| AWS S3 | cshelve[aws-s3] |
Supports access_key auth |
| Azure Blob | cshelve[azure-blob] |
Supports access_key, passwordless, connection_string, anonymous auth |
| In-Memory | none | Perfect for tests and temporary storage |
Detailed configuration in the documentation.
🤝 Contributing
We welcome pull requests, feature suggestions, and bug reports. Check the issues to get started.
📄 License
MIT – see LICENSE
⭐ Pro Tip
Switching from local to cloud to on-premises is as easy as:
db = cshelve.open('local.db')
# to
db = cshelve.open('aws-s3.ini')
# to
db = cshelve.open('sftp.ini')
No code rewrite. Just change the config.
Metadata
Release files for cshelve 1.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cshelve-1.6.0.tar.gz | 237.3 kB | Without provenance | Details for cshelve-1.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cshelve-1.6.0-py3-none-any.whl | Python 3 | none | any | Details for cshelve-1.6.0-py3-none-any.whl |
Total release size: 266.1 kB
Release files / cshelve-1.6.0.tar.gz
| Download URL | cshelve-1.6.0.tar.gz |
|---|---|
| Size | 237.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0457962cc4bc8480fd0cbb9f209cd2deafcdf5fb3df11aa97ffefa1a3f0dd299
|
|
BLAKE2b-256 checksum How to use checksums |
eafa943cce3e22207cc9079805d7bcac4504c6396695467d997bb90749101237
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cshelve-1.6.0-py3-none-any.whl
| Download URL | cshelve-1.6.0-py3-none-any.whl |
|---|---|
| Size | 28.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82528c2054921de4c3045b7e1e94cdfaa347e9562814e15962b642db10622e93
|
|
BLAKE2b-256 checksum How to use checksums |
3e374bab43cc0b50cfabf159945edc731997bc4291f74034e4f85c4e4a53f769
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for cshelve 1.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.