47 releases (10 stable)
|1.3.2||Jun 14, 2018|
|1.2.2||Apr 12, 2018|
|1.1.1||Jan 16, 2018|
|1.0.0-rc1||Dec 23, 2017|
|0.2.0||Nov 30, 2015|
#3 in Database interfaces
10,060 downloads per month
Used in 63 crates (60 directly)
Diesel is the most productive way to interact with databases in Rust because of its safe and composable abstractions over queries.
Diesel is an ORM and query builder designed to reduce the boilerplate for database interactions. If this is your first time reading this documentation, we recommend you start with the getting started guide. We also have many other long form guides.
So Diesel is able to validate your queries at compile time,
it requires you to specify your schema in your code,
which you can do with the
diesel print-schema or
infer_schema! can be used
to automatically generate these macro calls
(by connecting to your database and querying its schema).
Diesel provides a
which exports most of the typically used traits and types.
We are conservative about what goes in this module,
and avoid anything which has a generic name.
Files which use Diesel are expected to have
The tools the query builder gives you can be put into these three categories:
- "Query builder methods" are things that map to portions of a whole query
WHERE). These methods usually have the same name as the SQL they map to, except for
WHEREwhich is called
filterin Diesel (To not conflict with the Rust keyword). These methods live in the
- "Expression methods" are things you would call on columns
or other individual values.
These methods live in the
expression_methodsmodule You can often find these by thinking "what would this be called" if it were a method and typing that into the search bar (e.g.
likein Diesel). Most operators are named based on the Rust function which maps to that operator in
- "Bare functions" are normal SQL functions
sum. They live in the
dslmodule. Diesel only supports a very small number of these functions. You can declare additional functions you want to use with the
Types which represent the result of a SQL query implement
a trait called
Diesel maps "Rust types" (e.g.
i32) to and from "SQL types"
You can find all the types supported by Diesel in the
These types are only used to represent a SQL type.
You should never put them on your
To find all the Rust types which can be used with a given SQL type, see the documentation for that SQL type.
If you run into problems, Diesel has a very active Gitter room. You can come ask for help at gitter.im/diesel-rs/diesel Includes various helper types and bare functions which are named too generically to be included in prelude, but are often used when using Diesel. Provide helper types for concisely writing the return type of functions. As with iterators, it is unfortunately difficult to return a partially constructed query without exposing the exact implementation of the function. Without higher kinded types, these various DSLs can't be combined into a single trait for boxing purposes.
All types here are in the form
<FirstType as DslName<OtherTypes>>::Output. So the return type of
Limit<Order<FindBy<users, first_name, &str>, Asc<last_name>>>
Re-exports important traits and types. Meant to be glob imported when using Diesel.
- byteorder 1.0
- diesel_derives 1.3.0
- numeric? bigdecimal >= 0.0.10, < 0.0.12
- postgres? bitflags 1.0
- extras? chrono 0.4
- lint? clippy =0.0.195
- network-address? ipnetwork 0.12.2
- network-address? libc 0.2
libsqlite3-sys >=0.8.0, <0.10.0
- mysql? mysqlclient-sys >=0.1.0, <0.3.0
- numeric? num-bigint 0.1.41
- numeric? num-integer 0.1.32
- numeric? num-traits 0.2
- postgres? pq-sys >=0.3.0, <0.5.0
- optional quickcheck 0.4
- extras? r2d2 >= 0.8, < 0.9
- extras? serde_json >=0.8.0, <2.0
- deprecated-time? time 0.1
- mysql? url 1.4
uuid >=0.2.0, <0.7.0