Skip to main content

Simple threaded cassandra wrapper for asyncio

Project description

info:

Simple threaded cassandra wrapper for asyncio

https://img.shields.io/travis/aio-libs/aiocassandra.svg https://img.shields.io/pypi/v/aiocassandra.svg

Installation

pip install aiocassandra

Usage

import asyncio

from aiocassandra import aiosession
from cassandra.cluster import Cluster

cluster = Cluster()
session = cluster.connect()

# best way is to use cassandra prepared statements
cql = session.prepare('SELECT now() FROM system.local;')

@asyncio.coroutine
def main(*, loop):
    # patches and adds `execute_future` to `cassandra.cluster.Session`
    aiosession(session, loop=loop)
    return (yield from session.execute_future(cql))

loop = asyncio.get_event_loop()

try:
    response = loop.run_until_complete(main(loop=loop))
    print(response)
finally:
    cluster.shutdown()
    loop.close()

Python 2.7(trollius), 3.3+ and PyPy(trollius) are supported

Thanks

The library was donated by Ocean S.A.

Thanks to the company for contribution.

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

aiocassandra-1.1.0.tar.gz (3.6 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