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.

Source Distribution

sliceup-0.2.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

sliceup-0.2.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file sliceup-0.2.0.tar.gz.

File metadata

  • Download URL: sliceup-0.2.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8

File hashes

Hashes for sliceup-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cf116a8f3b6bce123032d65d9bf73d398c24e269e714c51c6a9458a6d77bb4b8
MD5 6bedfef7829206fee6c54f5f8f65e1d0
BLAKE2b-256 54c3821c565d8f6d59ae94b48c62726f75de832f0f86cf3c1878990f10a17479

See more details on using hashes here.

File details

Details for the file sliceup-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: sliceup-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8

File hashes

Hashes for sliceup-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 faab207aef070d914382c90aac61e6baeb3cb5c96401690f2e9bc1c1cbdfb62c
MD5 6d332554f67d739d406971994dc31090
BLAKE2b-256 69a93b562650dc893b1eec081308cd4d2bb2c0813d75715f16cbdde38da44c10

See more details on using hashes here.

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