KiteSQL

KipDataApache-2.0活跃维护

用 Rust 把 SQL 当函数调用的嵌入式数据库,自带类型安全 ORM,存储层可插拔 LMDB 或 RocksDB,适合在应用内直接做 OLTP 查询。

SQL as a Function for Rust — an embedded SQL database with a typed ORM and pluggable LMDB/RocksDB storage.

暂无版本760star +4 / 7 天54fork同步于 2026-11-11 05:51 UTC

怎么上手

由 README 提炼,执行前请确认
cargo run --bin kitesql-shell
cargo run --bin kitesql-shell -- -e "select 1"
硬件要求按 README 说明

README 未说明显存或 GPU 要求;为嵌入式数据库,随应用进程运行,无独立服务部署要求。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Rust 嵌入式 SQL 数据库,无需外部服务,支持类型化 ORM 与可插拔 KV 存储

用 Rust 把 SQL 当函数调用的嵌入式数据库,自带类型安全 ORM,存储层可插拔 LMDB 或 RocksDB,适合在应用内直接做 OLTP 查询。

核心能力

  • 支持大部分 SQL 2016 语法,可直接执行 SQL 语句
  • 元数据与数据统一存入 KV 存储,可切换 RocksDB、LMDB 或内存
  • 提供类型化 ORM,支持模型定义与 schema 迁移
  • 支持 builder 风格链式查询,按列过滤、投影与排序
  • 提供 WebAssembly 与 Python 绑定,可跨语言调用

容易踩的坑

RocksDB 为默认 feature,LMDB 需启用 lmdb feature,Python 绑定需启用 python feature;WebAssembly 需先安装 wasm-pack 并执行 wasm-pack build --release --target nodejs;TPC-C 基准测试需通过 make tpcc 运行,并可指定 --backend 选择后端。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Introduction

    KiteSQL is a lightweight embedded relational database written in Rust, inspired by MyRocks and SQLite. It runs inside your application with no external service: execute SQL directly, or use typed ORM models, migrations, and builder-style queries.

    • Most of the SQL 2016 syntax
    • All metadata and data stored in KV storage (RocksDB, LMDB, or in-memory)
    • Typed ORM with schema migration (orm feature), see src/orm/README.md
    • WebAssembly and Python bindings

    👉 More features · Blog

    📝 Zero-Copy SQL Computation on LMDB (中文): how strings travel from the mmap'd file to your struct without a copy, benchmarked against SQLite.

    Example

    use kite_sql::db::DataBaseBuilder;
    use kite_sql::errors::DatabaseError;
    use kite_sql::orm::OrmQueryResultExt;
    use kite_sql::Model;
    
    #[derive(Default, Debug, PartialEq, Model)]
    #[model(table = "users")]
    struct User {
        #[model(primary_key)]
        id: i32,
        #[model(varchar = 64)]
        name: String,
        #[model(default = "18", index)]
        age: Option<i32>,
    }
    
    fn main() -> Result<(), DatabaseError> {
        let mut database = DataBaseBuilder::path("./data").build_rocksdb()?;
        database.migrate::<User>()?;
    
        database.insert_many([
            User { id: 1, name: "Alice".to_string(), age: Some(18) },
            User { id: 2, name: "Bob".to_string(), age: Some(24) },
        ])?;
    
        let users = database
            .bind(|ctx| {
                ctx.from::<User>()?
                    .filter(|e| e.column(User::age())?.gte(18))?
                    .project_scalars((User::id(), User::name()))?
                    .order_by(User::name())?
                    .finish()
            })?
            .project_tuple::<(i32, String)>();
        for user in users {
            println!("{:?}", user?);
        }
    
        // Plain SQL works too.
        database.run("select count(*) from users")?.done()?;
        Ok(())
    }
    

    More: hello_world, transaction, program.

    Storage Backends

    BuilderStorage
    build_rocksdb()RocksDB (default feature rocksdb), stronger for write-heavy workloads
    build_lmdb()LMDB (feature lmdb), stronger for read-heavy workloads
    build_in_memory()In-memory, for tests and temporary data
    build_optimistic()RocksDB with optimistic transactions

    Feature flags, checkpoints, and transaction isolation: docs/features.md.

    Shell, WebAssembly, Python

    Shell

    cargo run --bin kitesql-shell
    cargo run --bin kitesql-shell -- -e "select 1"
    

    Type .help for metacommands.

    WebAssembly

    wasm-pack build --release --target nodejs
    
    import { WasmDatabase } from "./pkg/kite_sql.js";
    
    const db = new WasmDatabase();
    await db.ddl("create table demo(id int primary key, v int)");
    console.log(db.run("select * from demo").rows());
    

    Python

    Requires the python feature.

    import kite_sql
    
    db = kite_sql.Database.in_memory()  # or Database(path, backend="lmdb")
    db.execute("create table demo(id int primary key, v int)")
    print(list(db.run("select * from demo")))
    

    TPC-C

    make tpcc runs the benchmark (--backend kitesql-lmdb|kitesql-rocksdb|sqlite); make tpcc-dual cross-checks every statement against SQLite.

    720-second single-thread run on an i9-13900HX (32 GB, KIOXIA EXCERIA PLUS G3), every backend pinned to the same P-core and run without fsync on commit. Latencies are p90 in µs, including commit.

    BackendTpmCNew-OrderPaymentOrder-StatusDeliveryStock-Level
    KiteSQL LMDB2257202404425326179
    KiteSQL RocksDB487463437814014351587
    SQLite (WAL, synchronous=OFF)1921102704033342231

    👉 Details and how to reproduce

    Roadmap

    License

    KiteSQL uses the Apache 2.0 license to strike a balance between open contributions and allowing you to use the software however you want.

    Contributors