Skip to main content

A Python API for Lightblude database.

Project description

codecov.io

Build Status

This is python library for Lightblue database. It can be used as API interface.

Example of usage

Levels of abstraction (from low to high):

1) LightBlueEntity and LightBlueService

Basic modules to query a LightBlue on a level of the request.

2) LightBlueQuery

Class that represents a query to LB in time (both non-executed and executed states). Has a relation to the LightBlueEntity.

Usage example:

LightBlueQuery(_id='hash').find()
a = LightBlueQuery(('foo', '$neq', 'value'), bar='value2')
a._add_to_projection('foo', recursive=['bar'])
a._add_to_update(unset='foobar')
a.update()
LightBlueQuery.insert({'key': 'item'})

Why _add_to_projection() is private? Because we have another level of abstraction…

3) LightBlueGenericSelection

  • inherits LightBlueQuery and extends the functionality with post-processing, so you can call:

LightBlueGenericSelection(foo='value').find(
    check_response=True,
    selector='/processed/0/bar/',
    count=(1, 2),
    fallback=None,
    postprocess=lambda x: x.split('.')[-1])

so the query above will select documents with a specific foo value, it will check the successful query of a LB response and count of response documents of min 1 and max 2, with a fallback if it is out of range. It will select ‘bar’ from the first response item and will process it with the provided lambda.

That level of abstraction is generic because it is not specific to an entity.

Dependencies

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

python-lightblue-0.1.2.tar.gz (9.5 kB view details)

Uploaded Source

File details

Details for the file python-lightblue-0.1.2.tar.gz.

File metadata

File hashes

Hashes for python-lightblue-0.1.2.tar.gz
Algorithm Hash digest
SHA256 16d876aa2e35be5fcb0e4dab15fd55c802842706987afce98e97f132f9ea0db0
MD5 5c81fb17c173c03c3e5ed7189f708a11
BLAKE2b-256 eac56799eddc6400ef22d1021a58dd5a0498a15a8ceec76272700fcc4ff7be7f

See more details on using hashes here.

Supported by

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