7 releases (breaking)
Uses old Rust 2015
0.6.1 | Nov 8, 2017 |
---|---|
0.6.0 | Jun 10, 2017 |
0.5.0 | Jun 10, 2017 |
0.4.0 | Jun 9, 2017 |
0.1.0 | Jun 6, 2017 |
#2874 in Database interfaces
23KB
515 lines
Pinto
Pinto is a small, easy-to-use library for constructing SQL queries programmatically in Rust.
⚠️ This library does not provide query parameterization. Do not use raw user-supplied data in your queries. If inputs are not properly escaped, your software will be suspectible to SQL injection attacks.
Compatibility
The library aims to generate queries compatible with PostgreSQL, MySQL, and SQLite.
Install
Add pinto
as a dependency:
[dependencies]
pinto = "0.6.1"
Example
let query = query_builder::select("users")
.fields(&["id", "name"])
.filter("name = $1")
.order_by("id", query_builder::Order::Asc)
.build();
assert_eq!("SELECT id, name FROM users WHERE name = $1 ORDER BY id ASC;", query);
See included tests for additional examples.
Features
Statements
DELETE
WHERE
clause
INSERT
SELECT
- Table alias (
AS
) - Field selection
JOIN
clauseWHERE
clauseGROUP BY
clauseHAVING
clauseORDER BY
clauseLIMIT
andOFFSET
clause
- Table alias (
UPDATE
WHERE
clause
Documentation
- "First Steps" (recommended for beginners)
- API documentation
Design Philosophy
Pinto aims to be:
- Easy-to-use — the library should be useful with a beginner's knowledge of Rust
- Simple — the library's API should follow common SQL terminology and should allow its users to write concise, readable implementations
Other design goals, such as performance, are relevant but not foremost.
License
MIT