pynosqlc-cassandra
Cassandra 4 driver for pynosqlc — a JDBC-inspired unified async NoSQL access layer for Python.
Install this driver to connect pynosqlc to a Cassandra 4 instance using the
cassandra-driver library, bridged into Python's asyncio via
asyncio.run_in_executor. All pynosqlc operations — store, get, insert,
update, delete, and find — are supported.
Requirements
- Python 3.12+
- Cassandra 4.0+ instance (local or remote)
pynosqlc-coreandpynosqlc-memory(installed automatically as dependencies)
Installation
pip install alt-python-pynosqlc-cassandra
Quick Start
import asyncio
from pynosqlc.core import DriverManager, Filter
import pynosqlc.cassandra # auto-registers CassandraDriver on import
async def main():
async with await DriverManager.get_client(
'pynosqlc:cassandra:localhost:9042/my_keyspace'
) as client:
col = client.get_collection('orders')
# Store a document at a known key (upsert semantics)
await col.store('order-001', {'item': 'widget', 'qty': 5, 'status': 'pending'})
# Retrieve a document by key
doc = await col.get('order-001')
print(doc) # {'item': 'widget', 'qty': 5, 'status': 'pending', '_id': 'order-001'}
# Insert a document with a driver-assigned key
key = await col.insert({'item': 'gadget', 'qty': 2, 'status': 'pending'})
print(key) # e.g. 'a1b2c3d4-...'
# Update fields (shallow merge — only listed fields change)
await col.update('order-001', {'qty': 10, 'status': 'shipped'})
# Find documents matching a filter
f = Filter.where('status').eq('pending').build()
async for doc in await col.find(f):
print(doc)
# Delete a document
await col.delete('order-001')
asyncio.run(main())
URL Scheme
pynosqlc:cassandra:<host>:<port>/<keyspace>
| URL | Description |
|---|---|
pynosqlc:cassandra:localhost:9042/my_keyspace |
Local Cassandra, named keyspace |
pynosqlc:cassandra:cassandra.example.com:9042/prod |
Remote instance |
The <keyspace> segment is required. If the keyspace does not exist, the driver
creates it automatically using SimpleStrategy with replication factor 1. For
production use, create the keyspace manually with appropriate replication
settings before connecting.
Schema
Each pynosqlc collection maps to a Cassandra table in the configured keyspace:
CREATE TABLE IF NOT EXISTS <collection_name> (
pk TEXT PRIMARY KEY,
data TEXT
);
pk— the document key (string)data— the document serialised as a JSON string
Tables are created automatically on the first operation against a collection. You do not need to create tables manually.
Filtering
Filters are evaluated in-process after a full table scan. find() fetches
every row from the collection table, deserialises the data column, then
applies the pynosqlc filter AST in memory using MemoryFilterEvaluator. There
is no CQL WHERE clause generated.
This matches the design of the jsnosqlc Cassandra driver and is appropriate for development, testing, and moderate-sized collections. For production workloads with large tables, evaluate CQL secondary indexes or materialised views as complementary tools.
All filter operators are supported: eq, ne, gt, gte, lt, lte,
contains, in_, nin, exists, and their and_ / or_ / not_
combinators.
Async Integration
cassandra-driver uses a synchronous API. This driver wraps every blocking CQL
call in asyncio.get_event_loop().run_in_executor(None, ...) so the asyncio
event loop is never blocked. The default cassandra-driver reactor
(thread-based) is used. Do not set connection_class=AsyncioConnection —
AsyncioConnection hooks into the event loop from the main thread and cannot
be used from a thread-pool executor.
Troubleshooting
NoHostAvailable or ConnectionException on connect
Cassandra is not running or is not reachable on the configured host and port.
Verify with cqlsh <host> <port> — you should reach the CQL shell prompt.
ImportError: No module named 'pynosqlc.cassandra'
The package is not installed. Run pip install alt-python-pynosqlc-cassandra.
ValueError: No driver found for URL ...
The import import pynosqlc.cassandra was not executed before calling
DriverManager.get_client(...). The import is what triggers driver
registration — it must come before any get_client call.
InvalidRequest: Keyspace '<name>' does not exist
This should not occur in normal use because the driver creates the keyspace
automatically. If you see this error, check that the connecting user has
CREATE KEYSPACE permission, or create the keyspace manually:
CREATE KEYSPACE my_keyspace
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
Filter returns no results despite documents being present
Confirm you called .build() at the end of your filter chain:
Filter.where('field').eq('value').build(). Passing an unbuilt FieldCondition
object instead of the built dict will match nothing.
Further Reading
- pynosqlc API reference — complete method signatures
- Driver implementation guide — how pynosqlc drivers work
- Getting started tutorial — step-by-step introduction
Metadata
Release files for alt-python-pynosqlc-cassandra 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| alt_python_pynosqlc_cassandra-1.0.4.tar.gz | 6.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| alt_python_pynosqlc_cassandra-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.6 kB
Release files / alt_python_pynosqlc_cassandra-1.0.4.tar.gz
| Download URL | alt_python_pynosqlc_cassandra-1.0.4.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
35ec2baba7cbdaa5bde609a0cb887f5bd8895bd66ff0d2a083ef55744bf76ab5
|
|
BLAKE2b-256 checksum How to use checksums |
fffe20ff9093a95435e98097c5b7d5d8c97e156a304177d18dae012f580ae325
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / alt_python_pynosqlc_cassandra-1.0.4-py3-none-any.whl
| Download URL | alt_python_pynosqlc_cassandra-1.0.4-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c7e9c19595df7edcf112f6e595b0d1ab2fd50f4c9671419395e92e15608cce07
|
|
BLAKE2b-256 checksum How to use checksums |
bf66721a963ab5ce954311b249243c769920e93aeac2765846c3efdf6cd12b22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for alt-python-pynosqlc-cassandra 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.