Skip to main content

Python lightblue library

codecov

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(
    'https://data-url.com/data',
    'https://metadata-url.com/metadata')

interface = LightBlueEntity(
    lightblue_service=service,
    entity_name='foo',
    version='1.0.0')

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'])
a._add_to_update(unset='foobar')
a.update()
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(
    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

Metadata

Release files for python-lightblue 1.0.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 python-lightblue 1.0.3
File Size Uploaded
python-lightblue-1.0.3.tar.gz 33.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-lightblue 1.0.3
File Interpreter ABI Platform
python_lightblue-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 57.6 kB

Release files / python-lightblue-1.0.3.tar.gz

Download URL python-lightblue-1.0.3.tar.gz
Size 33.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2b93af0baa2bdf3a1791f2ecd35d6739d328c488afabe991cc2d777d4539ceec
BLAKE2b-256 checksum
How to use checksums
6818dafb9b292dc22fcdb4469e4dfacc766c4b170b806391978c748ddcc2441a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

Release files / python_lightblue-1.0.3-py3-none-any.whl

Download URL python_lightblue-1.0.3-py3-none-any.whl
Size 23.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a261ed71555d04b47cdde2645a70593a93cb1966d8bd553b8c1e088129d0d8e
BLAKE2b-256 checksum
How to use checksums
5cf97bd59d138118987546893cb9ce29bf10d0839b282ebc01dd3ad7211f5bd3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.1.6

2 release files

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

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