Skip to main content

Pyssandra

Cassandra object mapper using Pydantic models.

Example

import uuid

from cassandra.auth import PlainTextAuthProvider
from cassandra.cluster import Cluster
from pydantic import BaseModel, Field

from pyssandra import Pyssandra

cloud_config = {"secure_connect_bundle": "/path/to/secure-connect-dbname.zip"}
auth_provider = PlainTextAuthProvider(username="user", password="pass")
cluster = Cluster(cloud=cloud_config, auth_provider=auth_provider)
session = cluster.connect()

keyspace = "test"
db = Pyssandra(session, keyspace)


@db.table(partition_keys=["id"], index=["first"])
class User(BaseModel):
    """Test user model."""

    id: uuid.UUID = Field(default_factory=uuid.uuid4)
    first: str
    last: str


# Create DB Table.
db[User].sync()

# CRUD Methods.
user = User(first="Test", last="User")
await db[User].insert(user)
await db[User].find_one({"id": user.id})
page1 = await db[User].find_many(where={"first": "Test"}, page_size=10)
page2 = await db[User].find_many(where={"first": "Test"}, page_size=10, paging_state=page1.paging_state)
await db[User].update(user)
await db[User].delete({"id": user.id})

Metadata

Release files for pyssandra 0.12.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyssandra 0.12.4
File Size Uploaded
pyssandra-0.12.4.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyssandra 0.12.4
File Interpreter ABI Platform
pyssandra-0.12.4-py3-none-any.whl Python 3 none any Details

Total release size: 15.0 kB

Release files / pyssandra-0.12.4.tar.gz

Download URL pyssandra-0.12.4.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
616d05627b04e17683b732acf134de743597eb98c1e4fb673818fecee92e4aac
BLAKE2b-256 checksum
How to use checksums
645c77844977d246d3cab8ff7ed9b4512069d549b263417c7c989e923f2affde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.12 Linux/6.5.6-76060506-generic

Release files / pyssandra-0.12.4-py3-none-any.whl

Download URL pyssandra-0.12.4-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fbd277b38b78506d9bd200938c36d5e1b30ccdbf9b90c549a0556e66e19330db
BLAKE2b-256 checksum
How to use checksums
9928bb54e31c68bece42005bd48b1c5945119beafa599a43648b266c3b26cd33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.12 Linux/6.5.6-76060506-generic

Release history Release notifications | RSS feed

This release

0.12.4 This release

2 release files

0.10.5

2 release files

0.4.0

2 release files

0.3.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page