Skip to main content

A Python API for Lightblue database.

Project description

Python lightblue library


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.

from lightblue.service import LightBlueService
from lightblue.entity import LightBlueEntity

service = LightBlueService(

interface = LightBlueEntity(

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:

from lightblue.query import LightBlueQuery

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

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:
from lightblue.selection import LightBlueGenericSelection

LightBlueGenericSelection(foo='value', interface=interface).find(
    count=(1, 2),
    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.


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-1.0.3.tar.gz (33.9 kB view hashes)

Uploaded source

Built Distribution

python_lightblue-1.0.3-py3-none-any.whl (23.7 kB view hashes)

Uploaded py3

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