Expand description
§unistore-sqlite: SQLite 嵌入式数据库能力
为用户提供轻量级嵌入式数据库能力,适用于中小型应用。
§设计哲学
- 配置权交付:提供 SQLite 能力而非强制使用
- 零配置启动:合理的默认配置,开箱即用
- 类型安全:Rust 类型系统保护,减少运行时错误
§快速开始
ⓘ
use unistore_sqlite::EmbeddedDb;
// 创建应用数据库
let db = EmbeddedDb::open("my_inventory")?;
// 定义表结构
db.migrate(|m| {
m.version(1, "初始化库存表", |s| {
s.create_table("items", |t| {
t.id()
.text_not_null("name")
.integer_not_null("quantity")
.real("price")
.created_at();
})?;
Ok(())
});
})?;
// 插入数据
let item_id = db.insert("items")
.set("name", "笔记本电脑")
.set("quantity", 10)
.set("price", 5999.0)
.execute()?;
// 查询数据
let items = db.select("items")
.filter("quantity > ?", 0)
.order_desc("created_at")
.fetch_all()?;Macros§
- params
- 参数列表构建宏
Structs§
- Delete
Builder - DELETE 查询构建器
- Embedded
Db - 嵌入式数据库
- Insert
Builder - INSERT 查询构建器
- Migration
- 迁移信息
- Migration
Builder - 迁移构建器
- Migration
Report - 迁移报告
- Migrator
- 迁移执行器
- Row
- 查询结果行
- Schema
Builder - Schema 构建器
- Select
Builder - SELECT 查询构建器
- Sqlite
Capability - SQLite 嵌入式数据库能力
- Sqlite
Config - SQLite 配置
- Table
Builder - 表构建器
- Transaction
- 事务包装器
- Update
Builder - UPDATE 查询构建器
Enums§
- Connection
State - 连接状态
- Isolation
Level - 事务隔离级别
- Param
- 查询参数
- SqlValue
- SQLite 值类型
- Sqlite
Error - SQLite 操作错误
- Synchronous
Mode - 同步模式
- Transaction
State - 事务状态
Functions§
- with_
immediate_ transaction - 便捷的立即事务执行函数
- with_
transaction - 便捷的事务执行函数
Type Aliases§
- Rows
- 多行结果集