import toradb.
Open a database
toradb.connect(...) is an alias for the same local opener in current releases.
Create or open tables
Ingest documents
Search
strategy, query_vector, and explain.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Open a database, manage tables, search, and run SQL
import toradb.
import toradb
db = toradb.local("./my_db")
toradb.connect(...) is an alias for the same local opener in current releases.
docs = db.create_table("docs", mode="text")
existing = db.table("docs")
n = docs.add([
{"text": "Nikola Tesla alternating current motor", "tag": "history"},
"Marie Curie studied radioactivity",
])
print(f"added {n} documents")
results = docs.search("Nikola Tesla motor", top_k=5)
frame = results.to_pandas()
print(frame[["id", "score"]])
strategy, query_vector, and explain.
out = db.sql(
"SELECT id FROM docs SPARSE SEARCH body BM25('Nikola Tesla') LIMIT 5"
)
if hasattr(out, "to_pandas"):
print(out.to_pandas())
else:
print(out) # DDL / DESCRIBE text
msg = db.sql("CREATE INDEX idx ON docs (text) USING BM25")
# or
db.reindex("docs", using="BM25")
results.to_pandas()
results.to_polars() # requires polars
