Python implementation of MimicDB
Project description
Python Implementation of MimicDB
Python works with the Boto library.
Installation
By default, MimicDB requires Redis (although other backends can be used instead).
$ pip install redis $ pip install mimicdb
Quickstart
If you’re using Boto already, replace boto imports with mimicdb imports.
Change:
from boto.s3.connection import S3Connection from boto.s3.key import Key
To:
from mimicdb.s3.connection import S3Connection from mimicdb.s3.key import Key
Additionally, import the MimicDB object itself, and initiate the backend:
from mimicdb import MimicDB MimicDB()
After establishing a connection for the first time, sync the connection to save the metadata locally:
conn = S3Connection(KEY, SECRET) conn.sync()
Or sync only a couple buckets from the connection:
conn.sync('bucket1', 'bucket2')
After that, upload, download and list as you usually would. API calls that can be responded to locally will return instantly without hitting S3 servers. API calls that are made to S3 using MimicDB will be mimicked locally to ensure consistency with the remote servers.
Pass force=True to most functions to force a call to the S3 API. This also updates the local database.
Alternate Backends
Besides the default Redis backend, MimicDB has SQLite and in-memory backends available.
from mimicdb.backends.sqlite import SQLite MimicDB(SQLite())
from mimicdb.backends.memory import Memory MimicDB(Memory())
Documentation
Contributing
Fork the repo.
Run tests to ensure a clean, working slate.
Improve/fix the code.
Add test cases if new functionality introduced or bug fixed (100% test coverage).
Ensure tests pass.
Push to your fork and submit a pull request to the develop branch.
Tests
Run tests after installing nose and coverage.
$ nosetests --with-coverage --cover-package=mimicdb
Integration testing is provided by Travis-CI at travis-ci.org/nathancahill/mimicdb
Test coverage reporting is provided by Coveralls at coveralls.io/r/nathancahill/mimicdb
Benchmarks
Run benchmarks.py in the root of the repo:
$ python benchmarks.py Boto Time: 0.338411092758 MimicDB Time: 0.00015789039612 Factor: 2143x faster
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file MimicDB-1.0.1.tar.gz
.
File metadata
- Download URL: MimicDB-1.0.1.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9897b96c63d1f39848d559d2e8e5490186e1886c1ada8e6b903bdcd8b2a2d084 |
|
MD5 | 336a0c1143ba9fc8ce615dbfae28bc40 |
|
BLAKE2b-256 | 842e152ea40dd29de39d9ad41bbee1f07d80599c9b9af66dee367e794bb58641 |