AstraPy
AstraPy is a Pythonic SDK for DataStax Astra and Stargate
Resources
Getting Started
Install AstraPy
pip install astrapy
Using the HTTP Client
You can use the HTTP client to work with any Astra/Stargate endpoint. API Reference
from astrapy.rest import create_client, http_methods
import uuid
# get Astra connection information from environment variables
ASTRA_DB_ID = os.environ.get('ASTRA_DB_ID')
ASTRA_DB_REGION = os.environ.get('ASTRA_DB_REGION')
ASTRA_DB_APPLICATION_TOKEN = os.environ.get('ASTRA_DB_APPLICATION_TOKEN')
ASTRA_DB_KEYSPACE = os.environ.get('ASTRA_DB_KEYSPACE')
ASTRA_DB_COLLECTION = "test"
# setup an Astra Client
astra_http_client = create_client(astra_database_id=ASTRA_DB_ID,
astra_database_region=ASTRA_DB_REGION,
astra_application_token=ASTRA_DB_APPLICATION_TOKEN)
# create a document on Astra using the Document API
doc_uuid = uuid.uuid4()
astra_http_client.request(
method=http_methods.PUT,
path=f"/api/rest/v2/namespaces/{ASTRA_DB_KEYSPACE}/collections/{ASTRA_DB_COLLECTION}/{doc_uuid}",
json_data={
"first_name": "Cliff",
"last_name": "Wicklow",
"emails": ["cliff.wicklow@example.com"],
})
Using the Collections module
You can use the collections module to work with Documents in a simple way. API Reference
Refer to this file for comprehensive examples.
from astrapy.collections import create_client, AstraCollection
import uuid
# get Astra connection information from environment variables
ASTRA_DB_ID = os.environ.get('ASTRA_DB_ID')
ASTRA_DB_REGION = os.environ.get('ASTRA_DB_REGION')
ASTRA_DB_APPLICATION_TOKEN = os.environ.get('ASTRA_DB_APPLICATION_TOKEN')
ASTRA_DB_KEYSPACE = os.environ.get('ASTRA_DB_KEYSPACE')
TEST_COLLECTION_NAME = "test"
# setup an Astra Client and create a shortcut to our test colllection
astra_client = create_client(astra_database_id=ASTRA_DB_ID,
astra_database_region=ASTRA_DB_REGION,
astra_application_token=ASTRA_DB_APPLICATION_TOKEN)
test_collection = astra_client.namespace(ASTRA_DB_KEYSPACE).collection(TEST_COLLECTION_NAME)
# create a new document
cliff_uuid = str(uuid.uuid4())
test_collection.create(path=cliff_uuid, document={
"first_name": "Cliff",
"last_name": "Wicklow",
})
Metadata
Release files for astrapy 0.2.0
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 | Actions |
|---|---|---|---|---|
| astrapy-0.2.0.tar.gz | 8.5 kB | Without provenance | Details for astrapy-0.2.0.tar.gz |
Release files / astrapy-0.2.0.tar.gz
| Download URL | astrapy-0.2.0.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77fa529900661e920d21ab4790e7d76dfd7e159fd10c376c33e694eb2c23c531
|
|
BLAKE2b-256 checksum How to use checksums |
4cb0f31ed30be8fe1e033d61b67b743e62e2aed5ff8838835e64c62a4008bdde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.4
|
Security for astrapy 0.2.0
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.