Skip to main content

No project description provided

Project description

fastastra

commits Github Last Commit PyPI version Discord chat Stars

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


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.31.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastastra-0.1.31-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file fastastra-0.1.31.tar.gz.

File metadata

  • Download URL: fastastra-0.1.31.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.3 Linux/6.11.0-21-generic

File hashes

Hashes for fastastra-0.1.31.tar.gz
Algorithm Hash digest
SHA256 b7f0a84b2a05f6028ecb84df8bc6eae65e1f2fdbde0b33d8f0af8818fa379c7a
MD5 87e32e45cd4ddba582497b5a6e5d31df
BLAKE2b-256 2d7752de77040d0b8627a2a3dd31ea7e3caf99a6a7ad77d66adb1227b73436ec

See more details on using hashes here.

File details

Details for the file fastastra-0.1.31-py3-none-any.whl.

File metadata

  • Download URL: fastastra-0.1.31-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.3 Linux/6.11.0-21-generic

File hashes

Hashes for fastastra-0.1.31-py3-none-any.whl
Algorithm Hash digest
SHA256 7d1ffff00d20db93f190856f925d682636b31f00740179d74852d1c203ead5f7
MD5 48e9447587cfa6da155d1a664262930f
BLAKE2b-256 ec899ee3dd8bc349c3d0669c888c50e3c5fe4da5f4de2b81feade538a760ca04

See more details on using hashes here.

Supported by

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