pyssandra


Namepyssandra JSON
Version 0.12.4 PyPI version JSON
download
home_pagehttps://gitlab.com/mburkard/pyssandra
SummaryUse pydantic models to create basic CQL queries.
upload_time2023-11-10 16:41:40
maintainer
docs_urlNone
authorMatthew Burkard
requires_python>=3.9,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pyssandra

Cassandra object mapper using Pydantic models.

### Example

```python
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})
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/mburkard/pyssandra",
    "name": "pyssandra",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Matthew Burkard",
    "author_email": "matthewjburkard@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/64/5c/77844977d246d3cab8ff7ed9b4512069d549b263417c7c989e923f2affde/pyssandra-0.12.4.tar.gz",
    "platform": null,
    "description": "# Pyssandra\n\nCassandra object mapper using Pydantic models.\n\n### Example\n\n```python\nimport uuid\n\nfrom cassandra.auth import PlainTextAuthProvider\nfrom cassandra.cluster import Cluster\nfrom pydantic import BaseModel, Field\n\nfrom pyssandra import Pyssandra\n\ncloud_config = {\"secure_connect_bundle\": \"/path/to/secure-connect-dbname.zip\"}\nauth_provider = PlainTextAuthProvider(username=\"user\", password=\"pass\")\ncluster = Cluster(cloud=cloud_config, auth_provider=auth_provider)\nsession = cluster.connect()\n\nkeyspace = \"test\"\ndb = Pyssandra(session, keyspace)\n\n\n@db.table(partition_keys=[\"id\"], index=[\"first\"])\nclass User(BaseModel):\n    \"\"\"Test user model.\"\"\"\n\n    id: uuid.UUID = Field(default_factory=uuid.uuid4)\n    first: str\n    last: str\n\n\n# Create DB Table.\ndb[User].sync()\n\n# CRUD Methods.\nuser = User(first=\"Test\", last=\"User\")\nawait db[User].insert(user)\nawait db[User].find_one({\"id\": user.id})\npage1 = await db[User].find_many(where={\"first\": \"Test\"}, page_size=10)\npage2 = await db[User].find_many(where={\"first\": \"Test\"}, page_size=10, paging_state=page1.paging_state)\nawait db[User].update(user)\nawait db[User].delete({\"id\": user.id})\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Use pydantic models to create basic CQL queries.",
    "version": "0.12.4",
    "project_urls": {
        "Homepage": "https://gitlab.com/mburkard/pyssandra",
        "Repository": "https://gitlab.com/mburkard/pyssandra"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9928bb54e31c68bece42005bd48b1c5945119beafa599a43648b266c3b26cd33",
                "md5": "b0de76535272e6bf387ab2351a996a1c",
                "sha256": "fbd277b38b78506d9bd200938c36d5e1b30ccdbf9b90c549a0556e66e19330db"
            },
            "downloads": -1,
            "filename": "pyssandra-0.12.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b0de76535272e6bf387ab2351a996a1c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 7665,
            "upload_time": "2023-11-10T16:41:38",
            "upload_time_iso_8601": "2023-11-10T16:41:38.363691Z",
            "url": "https://files.pythonhosted.org/packages/99/28/bb54e31c68bece42005bd48b1c5945119beafa599a43648b266c3b26cd33/pyssandra-0.12.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "645c77844977d246d3cab8ff7ed9b4512069d549b263417c7c989e923f2affde",
                "md5": "20f1173b0254e2d644f0e1ea67704ccf",
                "sha256": "616d05627b04e17683b732acf134de743597eb98c1e4fb673818fecee92e4aac"
            },
            "downloads": -1,
            "filename": "pyssandra-0.12.4.tar.gz",
            "has_sig": false,
            "md5_digest": "20f1173b0254e2d644f0e1ea67704ccf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 7311,
            "upload_time": "2023-11-10T16:41:40",
            "upload_time_iso_8601": "2023-11-10T16:41:40.307068Z",
            "url": "https://files.pythonhosted.org/packages/64/5c/77844977d246d3cab8ff7ed9b4512069d549b263417c7c989e923f2affde/pyssandra-0.12.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-10 16:41:40",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "mburkard",
    "gitlab_project": "pyssandra",
    "lcname": "pyssandra"
}
        
Elapsed time: 0.95571s