Skip to content

databox/databox-python

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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