diesel
14,234
Stars
1,257
Forks
106
Watchers
174
Open Issues
Apache-2.0
许可证
Rust
语言
2015-08-29
创建时间
2026-11-12
最近更新
项目能做什么
Rust 的安全、可扩展 ORM 与查询构建器。
来源:基于仓库元数据
· 内容以仓库实际 README 为准
使用说明 查看原始 README 原仓库文档
中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
[](https://diesel.rs)
# A safe, extensible ORM and Query Builder for Rust
[](https://github.com/diesel-rs/diesel/actions?query=workflow%3A%22CI+Tests%22+branch%3Amain)
[](https://crates.io/crates/diesel)
API Documentation: [latest release](https://docs.rs/diesel) – [main branch](https://docs.diesel.rs/main/diesel/index.html)
[Homepage](https://diesel.rs)
Diesel gets rid of the boilerplate for database interaction and eliminates
runtime errors without sacrificing performance. It takes full advantage of
Rust's type system to create a low overhead query builder that "feels like
Rust."
Supported databases:
1. [PostgreSQL](https://docs.diesel.rs/main/diesel/pg/index.html)
2. [MySQL](https://docs.diesel.rs/main/diesel/mysql/index.html)
3. [SQLite](https://docs.diesel.rs/main/diesel/sqlite/index.html)
4. [MariaDB](https://docs.diesel.rs/main/diesel/mariadb/index.html)
You can configure the database backend in `Cargo.toml`:
```toml
[dependencies]
diesel = { version = "<version>", features = ["<postgres|mysql|sqlite>"] }
```
## Getting Started
Find our extensive Getting Started tutorial at
[https://diesel.rs/guides/getting-started](https://diesel.rs/guides/getting-started).
Guides on more specific features are coming soon.
## Getting help
If you run into problems, you can come ask for help at in our [GitHub Discussions](https://github.com/diesel-rs/diesel/discussions) forum.
This is also the right place to propose new features or show your applications.
## Usage
### Simple queries
Simple queries are a complete breeze. Loading all users from a database:
```rust
users::table.load(&mut connection)
```
Executed SQL:
```sql
SELECT * FROM users;
```
Loading all the posts for a user:
``` rust
Post::belonging_to(user).load(&mut connection)
```
Executed SQL:
```sql
SELECT * FROM posts WHERE user_id = 1;
```
### Complex queries
Diesel's powerful query builder helps you construct queries as simple or complex as
you need, at zero cost.
```rust
let versions = Version::belonging_to(krate)
.select(id)
.order(num.desc())
.limit(5);
let downloads = version_downloads
.filter(date.gt(now - 90.days()))
.filter(version_id.eq_any(versions))
.order(date)
.load::<Download>(&mut conn)?;
```
Executed SQL:
```sql
SELECT version_downloads.* FROM version_downloads
WHERE date > (NOW() - '90 days')
AND version_id = ANY(
SELECT id FROM versions
WHERE crate_id = 1
ORDER BY num DESC
LIMIT 5
)
ORDER BY date
```
### Less boilerplate
Diesel codegen generates boilerplate for you. It lets you focus on your business logic, not mapping to and from SQL rows.
That means you can write this:
```rust
#[derive(Queryable, Selectable)]
#[diesel(table_name = downloads)]
pub struct Download {
id: i32,
阅读完整原文
项目深度分析 规则生成(AI 未配置)
综合评分 42.0 分。该项目在“个人可实施性”维度得 35 分,“付费可能性”维度得 20.0 分,差异化空间 70.0 分(评分依据见评分卡)。
面向细分需求的二次开发产品
| 产品构想 | 基于 diesel 的核心能力,聚焦一个更窄的场景(如某平台、某行业)做差异化。 |
| 目标用户 | 该细分场景用户 |
| 难度/周期 | 中 · 2~6 周 |
| 收费模式 | 买断制 / 订阅制 / 广告 |
| 竞争风险 | 细分需求规模需验证 |
| 依据 | AI 推测:基于项目主题标签的判断 |
以上为规则引擎基于仓库公开数据生成的参考结论,包含推测成分,不构成投资或创业承诺;配置 AI 后可获得更深入的分析。
报告会保存到 个人中心
竞品与相似项目 GitHub Search 真实检索
相似项目数据正在完善中,暂不展示(避免误导)
项目优势与风险
| 技术成熟度 | 创建于 2015-08-29,近 30 天仍在推送,发布过 80 个 Release |
| 社区活跃 | Star 14,234 / Fork 1,257 / Issue 174(数据支持,可自行核实) |
| 许可证 | Apache-2.0 |
| 主要风险 | 上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价 |
安装与使用
此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。