Skip to main content

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

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')
    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


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.28.tar.gz (13.1 kB view hashes)

Uploaded Source

Built Distribution

fastastra-0.1.28-py3-none-any.whl (14.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page