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.

Source Distribution

asonic-1.0.3.tar.gz (5.0 kB view hashes)

Uploaded Source

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