Skip to main content

SSShelf

https://img.shields.io/pypi/v/ssshelf.svg https://travis-ci.org/voidfiles/ssshelf.svg?branch=master Code Climate Test Coverage

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

Goals

  • Lots of examples

  • Blob Storage as primary (S3, Ceph, Google Cloud Storage, etc.)

Concerns

  • Eventual Consistency

  • Speed

  • Constraints

Examples Using SSShelf

Example

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': 'http://google.com',
        'created_at': datetime.utcnow()
    }

    await bookmark_manager.add_item(bookmark)

    resp = await bookmark_manager.every.get_items()

    assert resp['items'][0]['link'] == 'http://google.com'

loop = asyncio.get_event_loop()
loop.run_until_complete(demo())

Metadata

Release files for ssshelf 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ssshelf 0.1.3
File Size Uploaded Provenance
ssshelf-0.1.3.tar.gz 8.8 kB Without provenance Details

Release files / ssshelf-0.1.3.tar.gz

Download URL ssshelf-0.1.3.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0889319c2f1bf13a817e7ccb5a9d5a3c123557592cff37752223dc4dfa306694
BLAKE2b-256 checksum
How to use checksums
db274d6be28bddc73974357353d1192abbacae9972e2a099dc6352c488cc5f8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for ssshelf 0.1.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page