Async python client for Sonic database
Project description
Install
pip install asonic
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)
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-0.1.1.tar.gz
(4.6 kB
view hashes)