Skip to main content

Async python client for Sonic database

Project description

Asonic implements all Sonic APIs
Bugfixes and api changes are welcome

Install

pip install asonic

API Docs

here

Usage

Search channel

import asyncio

from asonic import Client
from asonic.enums import Channels


async def main():
  c = Client(host='127.0.0.1', port=1491, password='SecretPassword', max_connections=100)
  await c.channel(Channels.SEARCH.value)  # or simply search
  await c.query('collection', 'bucket', 'quick') == 'user_id'
  await c.suggest('collection', 'bucket', 'br', 1) == 'brown'

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Ingest channel

import asyncio

from asonic import Client
from asonic.enums import Channels


async def main():
  c = Client(host='127.0.0.1', port=1491)
  await c.channel(Channels.INGEST.value)  # or simply ingest
  await c.push('collection', 'bucket', 'user_id', 'The quick brown fox jumps over the lazy dog')
  # Return b'OK'
  await c.pop('collection', 'bucket', 'user_id', 'The')
  # Return 1

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Control channel

import asyncio

from asonic import Client
from asonic.enums import Channels, Actions


async def main():
  c = Client(host='127.0.0.1', port=1491)
  await c.channel(Channels.CONTROL.value)  # or simply control
  await c.trigger(Actions.CONSOLIDATE) # or simply consolidate
  # Return b'OK'
  await ingest.pop('collection', 'bucket', 'user_id', 'The')
  # Return 1

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Project details


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
asonic-1.0.2.tar.gz (4.9 kB) Copy SHA256 hash SHA256 Source None

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 SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page