9 unstable releases

Uses old Rust 2015

0.4.3 Mar 8, 2018
0.4.2 Jun 16, 2017
0.4.1 Nov 7, 2016
0.4.0 Aug 1, 2016
0.0.1 Aug 2, 2015

#1574 in Database interfaces

21 downloads per month

Apache-2.0/MIT

28KB
716 lines

SQLite Package Documentation Build

The package provides a constructor of SQL statements.

Example

use sql::prelude::*;

// CREATE TABLE `users` (`id` INTEGER NOT NULL, `name` TEXT, `photo` BLOB)
println!("{}", create_table("users").column("id".integer().not_null())
                                    .column("name".string())
                                    .column("photo".binary())
                                    .compile().unwrap());

// DELETE FROM `users`
println!("{}", delete_from("users").compile().unwrap());

// INSERT INTO `users` (`id`, `name`) VALUES (?, ?), (?, ?)
println!("{}", insert_into("users").columns(&["id", "name"]).batch(2)
                                   .compile().unwrap());

// SELECT * FROM `users` WHERE `name` LIKE 'A%'
println!("{}", select_from("users").so_that(column("name").like("A%"))
                                   .compile().unwrap());

// SELECT * FROM `users` ORDER BY `name` DESC
println!("{}", select_from("users").order_by(column("name").descend())
                                   .compile().unwrap());

// SELECT `name`, `photo` FROM `users` LIMIT 1
println!("{}", select_from("users").columns(&["name", "photo"]).limit(1)
                                   .compile().unwrap());

Contribution

Your contribution is highly appreciated. Do not hesitate to open an issue or a pull request. Note that any contribution submitted for inclusion in the project will be licensed according to the terms given in LICENSE.md.

No runtime deps