No project description provided
Project description
fastastra
fastastra is modeled after fastlite and it allows you to use FastHTML with AstraDB (Cassandra).
Installation
poetry add fastastra
or
pip install fastastra
To connect:
from fastastra.fastastra import AstraDatabase
db = AstraDatabase(token, dbid) # get your token and dbid from https://astra.datastax.com
Basic usage
List tables
db.t
Create a table
cats = db.t.cats
if cats not in db.t:
cats.create(cat_id=uuid.uuid1, name=str, partition_keys='cat_id')
Insert a row
cat_timeuuid = uuid.uuid1()
cats.update(cat_id=cat_timeuuid, name="fluffy")
List all rows
rows = cats()
ANN / vector search
db = AstraDatabase(token, dbid, embedding_model="embed-english-v3.0") # supports all embedding models in LiteLLM using env vars
dogs = db.t.dogs
if dogs not in db.t:
#dogs.create(id=int, name=str, good_boy=bool, embedding=(list[float], 2), pk='id') # specify dimensions in create
dogs.create(id=int, name=str, good_boy=bool, embedding=list[float], pk='id') # infer dimensions from db.embedding_model
dogs.c.good_boy.index()
dogs.c.embedding.index()
dogs.insert(id=2, good_boy=True, name="spike", embedding=[0.1, 0.2])
index_lookukp = dogs.xtra(good_boy=True)
ann_matches = dogs.xtra(embedding=[0.2, 0.2])
Get dataclass and pydantic model
dataclass = cats.dataclass()
model = cats.pydantic_model()
Get a row
print(cats[cat_timeuuid])
Delete a row
cats.delete(cat_timeuuid)
or
cats.delete(str(cat_timeuuid))
Run a FastHTML example:
This example was taken almost verbatim from the FastHTML examples repo. The only change was the dependency, the db connection string, and changing the id from int
to uuid1
.
poetry install
poetry run python examples/todo.py
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
fastastra-0.1.30.tar.gz
(13.7 kB
view details)
Built Distribution
File details
Details for the file fastastra-0.1.30.tar.gz
.
File metadata
- Download URL: fastastra-0.1.30.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.8 Linux/6.5.0-1027-oem
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a194828ab0f1c17f5711a5fd57e3c9da9792ca29fc5e996474f271f58700c26 |
|
MD5 | a3183a0182149016292897c2c144923a |
|
BLAKE2b-256 | 1c6ec1a59263deeaff8bfdb07c8ecfadcbb6181e76ee425f31edda4d67351a03 |
File details
Details for the file fastastra-0.1.30-py3-none-any.whl
.
File metadata
- Download URL: fastastra-0.1.30-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.8 Linux/6.5.0-1027-oem
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6d17d14ac2a4bc94b9aa5603bcdeba20b91edeb898600ee61b3b585c260a401 |
|
MD5 | 40ae2114026c5c07ff634a4a74d74087 |
|
BLAKE2b-256 | 14534cb2dfd63443fa7294d589786979f7169cd838d0213695af89de2d6aba56 |