Skip to main content

Python client for SliceUp

Project description

Sliceup

PyPI PyPI - Downloads GitHub

Python client of the SliceUp API

Installing

$ pip install sliceup

Examples

Importing

from sliceup import *

Database summary

from sliceup import *

sliceup = Sliceup('demo.sliceup.co')

response = sliceup.summary()

if response:
    print(response.content)
else:
    print('An error has occurred.')

Create a table

from sliceup import *

sliceup = Sliceup('demo.sliceup.co')

response = sliceup.create({
    'name': 'orders',
    'columns': [
       {'name': 'time', 'type': 'time'},
       {'name': 'qty', 'type': 'int'},
       {'name': 'price', 'type': 'float'}
    ],
    'recreate': True
})

if response:
    print(response.content)
else:
    print('An error has occurred.')

Insert data

from sliceup import *

sliceup = Sliceup('demo.sliceup.co')

response = sliceup.insert({
    'name': 'orders', 
    'rows': [
        {'time': '00:00:00', 'qty': 2, 'price': 9.0},
        {'time': '00:30:09', 'qty': 2, 'price': 2.0},
        {'time': '01:45:01', 'qty': 4, 'price': 1.0},
        {'time': '12:10:33', 'qty': 10, 'price': 16.0},
        {'time': '16:00:09', 'qty': 4, 'price': 8.0},
        {'time': '22:00:00', 'qty': 4, 'price': 23.0},
        {'time': '22:31:49', 'qty': 4, 'price': 45.0},
        {'time': '22:59:19', 'qty': 4, 'price': 17.0},
    ]
})

if response:
    print(response.content)
else:
    print('An error has occurred.')

Query data

Check out in RunKit

Select from table

from sliceup import *

sliceup = Sliceup('demo.sliceup.co')

response = sliceup.query({
    'select': ['time', 'qty', 'price'],
    'from': 'orders'
})

if response:
    print(response.content)
else:
    print('An error has occurred.')

Visualize data

from sliceup import *

sliceup = Sliceup('demo.sliceup.co')

response = sliceup.query({
    'select': ['time', 'qty', 'price'],
    'from': 'orders'
})

if response:
    print(response.content)
else:
    print('An error has occurred.')

Query table statistics

from sliceup import *

sliceup = Sliceup('demo.sliceup.co')

response = sliceup.query({
   'select': [max('time'), min('time'), min('qty'), max('qty'), min('price'), max('price')],
   'from': 'orders'
})

if response:
    print(response.content)
else:
    print('An error has occurred.')

Slice the data into hour buckets

from sliceup import *

sliceup = Sliceup('demo.sliceup.co')

response = sliceup.query({
  'select': count('price'),
  'by': bar('time', time(1,0,0)),
  'from': 'orders'
})

if response:
    print(response.content)
else:
    print('An error has occurred.')

Slice and group the quantity by bars of 2

from sliceup import *

sliceup = Sliceup('demo.sliceup.co')

response = sliceup.query({
   'select': count('price'),
   'by': bar('qty', 2),
   'from': 'orders'
})

if response:
    print(response.content)
else:
    print('An error has occurred.')

License

Sliceup is copyright (c) 2019-present SliceUp, Inc.

Sliceup is free software, licensed under the MIT. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sliceup, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size sliceup-0.2.0-py3-none-any.whl (5.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size sliceup-0.2.0.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page