Databox bindings for Python
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
databox test
databox
.env Adding workon and mkvirtualenv support. Jun 3, 2015
.gitignore
.travis.yml
CHANGELOG.md
LICENSE.txt
README.md small changes Mar 20, 2018
example.py
requirements.txt
setup.cfg
setup.py

README.md

Databox bindings for Python

Build Status PyPI version

Setup

You can install this package by cloning this directory and running:

python setup.py install

You can also add following line to requirements.txt and get latest master:

git+https://github.com/databox/databox-python.git

And run pip install --upgrade -r requirements.txt. Or just:

pip install databox

Getting Databox access tokens

When in Databox Designer go to Data Manager and create new connection. Select "Push custom data" and enter a connection name.

Using the Databox Python library

To use databox-python libary you have to pass access token to client. You can do this when initialising Client or by setting DATABOX_PUSH_TOKEN environment variable.

Using Client and push to push data directly:

from databox import Client

client = Client('<access token>')
client.push('sales.total', 1447.0)
client.push('orders.total', 32, date='2015-01-01 09:00:00')
client.push('orders.total', 34, attributes={
  'something': 1447,
})

Inserting multiple matrices with one insert_all:

client.insert_all([
    {'key': 'temp.boston', 'value': 51},
    {'key': 'temp.boston', 'value': 49, 'date': '2015-01-01 17:00:00'},
    {'key': 'sales.total', 'value': 3000},
])

Retriving information from last push with last_push:

print client.last_push()

Libary can be used with shorthand methods:

from databox import push, insert_all, last_push

push('sales.total', 1448.9)
print last_push(token)

Development and testing

Using virtualenv:

mkvirtualenv --no-site-packages databox-python
workon databox-python
pip install --upgrade -r requirements.txt

Running test suite with unittest:

python -munittest discover -p -t . 'test*' -v

You can also check working example.py.

Examples and use-cases

Authors and contributions

Licence