Skip to main content

Talon — AI-native multi-model data engine (SQL + KV + Vector + TimeSeries + MQ + FTS + GEO + Graph + AI)

Project description

Talon Python SDK

基于 ctypes 封装 talon_execute C ABI,零编译依赖。

安装

pip install talon-db

Native library 在首次 import talon 时自动从 GitHub Releases 下载,无需手动编译。

快速开始

from talon import Talon

with Talon("./my_data") as db:
    # SQL
    db.sql("CREATE TABLE t (id INT, name TEXT)")
    db.sql("INSERT INTO t VALUES (1, 'hello')")
    rows = db.sql("SELECT * FROM t")

    # KV
    db.kv_set("key", "value", ttl=60)
    print(db.kv_get("key"))

    # 时序
    db.ts_create("metrics", tags=["host"], fields=["cpu"])
    db.ts_insert("metrics", {
        "timestamp": 1000,
        "tags": {"host": "srv1"},
        "fields": {"cpu": 0.85},
    })

    # 消息队列
    db.mq_create("events")
    db.mq_publish("events", "hello world")
    msgs = db.mq_poll("events", "g1", "c1", count=10)

    # 向量
    db.vector_insert("idx", 1, [0.1, 0.2, 0.3])
    results = db.vector_search("idx", [0.1, 0.2, 0.3], k=5)

    # AI 会话
    db.ai_create_session("s1", metadata={"model": "gpt-4"})
    db.ai_append_message("s1", {
        "role": "user", "content": "hello",
        "token_count": 1,
    })
    history = db.ai_get_history("s1")

测试

pip install talon-db
python3 tests/test_sdk.py

库查找优先级

SDK 按以下顺序查找 libtalon 动态库:

  1. TALON_LIB_PATH 环境变量
  2. 包内 talon/native/ 目录(platform wheel)
  3. SDK 开发布局 talon-sdk/lib/{platform}/
  4. 缓存目录(自动从 GitHub Releases 下载)
  5. 系统搜索路径

特性

  • 零编译依赖:仅用 Python 标准库 ctypes,无需安装额外包
  • 全引擎覆盖:SQL / KV / TS / MQ / Vector / AI 六大模块
  • Value 自动解包:SQL 结果自动转换为 Python 原生类型(int/float/str/bool/dict/list)
  • Context Manager:支持 with Talon(path) as db: 自动关闭
  • 类型注解:完整 typing 注解,IDE 友好

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

talon_db-0.1.41.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

talon_db-0.1.41-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file talon_db-0.1.41.tar.gz.

File metadata

  • Download URL: talon_db-0.1.41.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for talon_db-0.1.41.tar.gz
Algorithm Hash digest
SHA256 2d75bcb9dcace9ab5c12b0f81674b3cffea6add4e2c08f7f15c445d9af1838ae
MD5 f5429df5be29d17692d7d8b25cdf6e66
BLAKE2b-256 141bb89f8f52dd9e28a44c3d2a5c761d4221fcd9aeabe2e9ae3d92be624d33fd

See more details on using hashes here.

File details

Details for the file talon_db-0.1.41-py3-none-any.whl.

File metadata

  • Download URL: talon_db-0.1.41-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for talon_db-0.1.41-py3-none-any.whl
Algorithm Hash digest
SHA256 4a8d888070cc30af43c68d2e4072d6803ea33b925238fc5e847ff4b8f5b213d4
MD5 5bf378a6df62d1a8f991993825ab2f9c
BLAKE2b-256 2c92fd8c91c5a0226c2a2f3f34ab6a16dc7ffcc5e60614a40192e45063c3b3a0

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