AstraPy is a Pythonic SDK for DataStax Astra
Project description
AstraPy
AstraPy is a Pythonic SDK for DataStax Astra and Stargate
Resources
Getting Started
Install AstraPy
pip install astrapy
Setup your Astra client
Create a .env file with the appropriate values, or use the 'astra' cli to do the same.
ASTRA_DB_KEYSPACE="<keyspace>"
ASTRA_DB_APPLICATION_TOKEN="<AstraCS:...>"
ASTRA_DB_REGION="<region>"
ASTRA_DB_ID=<db_id>
Load the variables in and then create the client. This collections client can make non-vector and vector calls, depending on the call configuration.
import os
from dotenv import load_dotenv
from astrapy.db import AstraDB, AstraDBCollection
load_dotenv()
# Grab the new information from the database
db_id = os.getenv("ASTRA_DB_ID")
token = os.getenv("ASTRA_DB_APPLICATION_TOKEN")
# Initialize our vector db
astra_db = AstraDB(db_id=db_id, token=token)
# Create a new collection
astra_db.create_collection(name="collection_test", size=5)
# Collections
astra_db_collection = AstraDBCollection(
collection="collection_test",
astra_db=astra_db
)
# Insert some data into the collection
astra_db_collection.insert_one(
{
"_id": "1",
"name": "Coded Cleats Copy",
"description": "ChatGPT integrated sneakers that talk to you",
"$vector": [0.25, 0.25, 0.25, 0.25, 0.25],
}
)
# Find the inserted data!
astra_db_collection.find_one({"name" : "Coded Cleats Copy"})
More Information
Check out the notebook which has examples for finding and inserting information into the database, including vector commands.
Take a look at the vector tests and the collection tests for specific endpoint examples.
Using the Ops Client
You can use the Ops client to work the with Astra DevOps API. Check the devops tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file astrapy-0.5.0.dev4.tar.gz
.
File metadata
- Download URL: astrapy-0.5.0.dev4.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcf06dc46c953200164191b3ec6346c62fd1e695a6671e861f21ff0d850e1e7c |
|
MD5 | 52c415ebd73f651873376d93fc49a9bd |
|
BLAKE2b-256 | 906c5feaafaabc6724946aa992b06dd105fae2b8eda2f101e169dfc8906bc228 |
File details
Details for the file astrapy-0.5.0.dev4-py3-none-any.whl
.
File metadata
- Download URL: astrapy-0.5.0.dev4-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47c256e1dff63aa8160bcd7ec2801d861688ea4edd6179d480ac9b907813873c |
|
MD5 | 5d22cdead632f50ec62acd3f8cf0f084 |
|
BLAKE2b-256 | c7312c938786ecc0724fced745879a0511629dd779a96d45869301ab91d7e799 |