A high performance asynchronous Cassandra and Scylla client
Project description
WORK IN PROGRESS, use only for developing
Install
There is an Alpha realease compabitble with Python 3.7, 3.8 and 3.9 for Linux and MacOS environments uploaded as a Pypi package. Use the following command for installing it:
pip install acsylla
For MacOS you would need to install the following libraries for make it work:
brew install libuv openssl
Usage
The following snippet shows the minimal stuff that would be needed for creating a new Session object for the keyspace acsylla and then peform a query for reading a set of rows.
import asyncio
import acsylla
async def main():
cluster = acsylla.create_cluster([host])
session = await cluster.create_session(keyspace="acsylla")
statement = ascylla.create_statement("SELECT id, value FROM test WHERE id=100")
result = await session.execute(statement)
row = result.first()
value = row.column_value("value")
await session.close()
asyncio.run(main())
Acsylla comes with a minimal support for the following objects: Cluster, Session, Statement, PreparedStatement, Batch, Result, Row.
Acsylla supports all native datatypes including Collections and UDT
Example for use prepared statement and paging.
import asyncio
import acsylla
async def main()
cluster = acsylla.create_cluster(['localhost'])
session = await cluster.create_session(keyspace="acsylla")
prepared = await session.create_prepared("SELECT id, value FROM test")
statement = prepared.bind(page_size=10, timeout=0.01)
while True:
result = await session.execute(statement)
print(result.columns_names())
# ['id', 'value']
for row in result:
print(dict(row))
# {'id': 1, 'value': 'test'}
print(list(row))
# [('id', 1), ('value', 'test')]
print(row.as_list())
# [1, 'test']
print(row.as_tuple())
# (1, 'test')
if result.has_more_pages():
statement.set_page_size(100) # you can change statement settings on the fly
statement.set_page_state(result.page_state())
else:
break
asyncio.run(main())
Example for use Shard-Awareness connection to Scylla cluster.
import acsylla
cluster = acsylla.create_cluster(['node1', 'node2', 'node3'],
port=19042, # default: 9042
protocol_version=4, # default: 3
core_connections_per_host=8,# default: 1
local_port_range_min=49152, # default: 49152
local_port_range_max=65535 # default: 65535
)
SSL Connection example
import acsylla
with open('./certs/client.cert.pem') as f:
ssl_cert = f.read()
with open('./certs/client.key.pem') as f:
ssl_private_key = f.read()
with open('./certs/trusted.cert.pem') as f:
ssl_trusted_cert = f.read()
cluster = create_cluster(['localhost'],
ssl_enabled=True,
ssl_cert=ssl_cert,
ssl_private_key=ssl_private_key,
ssl_trusted_cert=ssl_trusted_cert,
ssl_verify_flags=acsylla.SSLVerifyFlags.PEER_IDENTITY)
Developing
For developing you must clone the respository and first compile the CPP Cassandra driver, please follow the instructions for installing any dependency that you would need for compiling the driver:
git clone git@github.com:pfreixes/acsylla.git
make install-driver
Set up the environment and compile the package using the following commands:
python -m venv venv
source venv/bin/activate
make compile
make install-dev
And finally run the tests:
docker-compose up -d
make test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for acsylla-0.1.7a0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a1950c1137a980b04346fab2e2e27fb3f37561f2c7c7e2d91b2394eeb5af443 |
|
MD5 | 0d05d0c139d8b28815473fa1c5a08927 |
|
BLAKE2b-256 | 6f7a14e35f0ee17e8ac30685c076c96dff5b9534b52a1de3b743c3d01b7d39ea |
Hashes for acsylla-0.1.7a0-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a45188e93655072b2c820355d1e93fd3313ba77fd511f8e0b5ad96a808207881 |
|
MD5 | 745094997f92c8347653b8f292cdae75 |
|
BLAKE2b-256 | 525a7996678d7342391cdcb2302a4f0ecefe5abfc794c37438505dabd093292c |
Hashes for acsylla-0.1.7a0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e64ac4817d31dc5be9d79b5dcff3b8ce11a736e65e0589512c7fbc528c46a4b1 |
|
MD5 | 2915f21af79eba41259cf05e7c1b09f9 |
|
BLAKE2b-256 | 22edd52129e1ceb1f38b3ecfa5059c6e116e46770a0f4f349602196c173b2109 |
Hashes for acsylla-0.1.7a0-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6525a6f7546c1c11760083551211a52b1f315b72dfd37712a313f49c1cbd652d |
|
MD5 | 1bf7ef3181e6fa92584dde5fa6c8e8a0 |
|
BLAKE2b-256 | 5c6b62c5b941135591eb4773d3fcfc99d9425c8c0d637abaa7e1f5e07b715d84 |
Hashes for acsylla-0.1.7a0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee91c8eecf7bbf17b3549af656f4f8c367a0f4a61fcfc939bf491494eec5670a |
|
MD5 | 46bf44859661d535935975fc761a1e1f |
|
BLAKE2b-256 | 1ea4228b84c3df94c06f41e0d7fbbbbef82f29391bebd55f8662d4b84cfadc95 |
Hashes for acsylla-0.1.7a0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bde7d4d38dbc28d9c309094eccc05693f35b0173767adb7023f1d0a69a22e04c |
|
MD5 | 5a34e5affa54f1afe1dbdc2c024caa04 |
|
BLAKE2b-256 | 37552d36953091f5d884bba043543b021b34a4479ea6c34c45aaa5364c6e25f4 |
Hashes for acsylla-0.1.7a0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d253dabdcb24288e687cdc67d5f99b65b7bb3a8e14a294f312b8d137c2a4bbd0 |
|
MD5 | 8527594b6da9661be8ce7892abe0022a |
|
BLAKE2b-256 | 84f4876870e02deb5fe0448ebbf98cd8c864e7de9840208d7d591222ce7f8a16 |
Hashes for acsylla-0.1.7a0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f07796fbd41e7e725bf7f07a2fa0c946cde375102a99262f5c4a9ceb34dd5846 |
|
MD5 | 8344de355b51e2a2bff8cdad5c151360 |
|
BLAKE2b-256 | c5b6e87b42b6a7d1d0cd008f6ef647a31a550c5bc3d16ea47a8d0e991c595b15 |