Skip to main content

Key-Value DB API on the filesystem

Project description

Kv Fs

Simple Key-Value DB implementation on the filesystem

Usage

  • Predefined formats

    from kv.fs.json import json_api
    
    api = json_api('base_path')
    api.insert('greetings/hello', dict(hello='world')) # saves onto 'base_path/greetings/hello.json'
    api.read('greetings/hello') # Right(value=dict(hello='world'))
    
  • Or build your own:

    from kv.fs import FilesystemKV
    from kv.api.errors import InvalidData
    import haskellian.either as E
    import json
    
    def parse(x: bytes) -> E.Either[InvalidData, Any]:
      try:
        return E.Right(json.loads(x))
      except json.decoder.JSONDecodeError as e:
        return E.Left(InvalidData(e))
    
    api = FilesystemKV(base_path='data', extension='.json', parse=parse, dump=json.dumps)
    

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

kv_fs-0.1.11.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

kv_fs-0.1.11-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page