Skip to main content

A collection and persistance manager for blob stores like aws S3

Project description

An S3 persistance manager. If you squint closely enough you could even call it a database.


  • High test coverage
  • Lots of examples
  • Treat s3 like a database


  • Eventual Consistency
  • Speed
  • Constraints


import asyncio
from datetime import datetime
import simpleflake
import json

from ssshelf.items import IManager
from ssshelf.collections import Collection
from ssshelf.utils import convert_datetime_to_str, json_dump
from ssshelf.managers import CManager
from ssshelf.storages.s3 import S3Storage

class Bookmark(IManager):
    def get_pk(self, item):
        return str(item['pk'])

    def serialize_item(self, item):
        return bytes(json_dump(item), 'utf8')

    def deserialize_item(self, data):
        return json.loads(data)

class AllBookmarks(Collection):
    def get_pk(self, item):
        return str(item['pk'])

    def key(self, item):
        return convert_datetime_to_str(item['created_at'])

class BookmarkManager(CManager):
    item_manager = Bookmark()
    every = AllBookmarks()

async def demo():
    bookmark_manager = BookmarkManager(S3Storage())

    bookmark = {
        'pk': simpleflake.simpleflake(),
        'link': '',
        'created_at': datetime.utcnow()

    await bookmark_manager.add_item(bookmark)

    items = await bookmark_manager.every.get_items()

    assert resp['items'][0]['link'] == ''

loop = asyncio.get_event_loop()

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ssshelf, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size ssshelf-0.0.3.tar.gz (6.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page