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})
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyssandra-0.12.4.tar.gz
(7.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyssandra-0.12.4.tar.gz.
File metadata
- Download URL: pyssandra-0.12.4.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.1.12 CPython/3.10.12 Linux/6.5.6-76060506-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
616d05627b04e17683b732acf134de743597eb98c1e4fb673818fecee92e4aac
|
|
| MD5 |
20f1173b0254e2d644f0e1ea67704ccf
|
|
| BLAKE2b-256 |
645c77844977d246d3cab8ff7ed9b4512069d549b263417c7c989e923f2affde
|
File details
Details for the file pyssandra-0.12.4-py3-none-any.whl.
File metadata
- Download URL: pyssandra-0.12.4-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.1.12 CPython/3.10.12 Linux/6.5.6-76060506-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbd277b38b78506d9bd200938c36d5e1b30ccdbf9b90c549a0556e66e19330db
|
|
| MD5 |
b0de76535272e6bf387ab2351a996a1c
|
|
| BLAKE2b-256 |
9928bb54e31c68bece42005bd48b1c5945119beafa599a43648b266c3b26cd33
|