#toql #query-parser #orm #productive #friendly

toql_query_parser

Library with parser for query parser for Toql

3 unstable releases

0.4.0 Dec 4, 2021
0.3.1 Oct 20, 2021
0.3.0 Oct 20, 2021

#2193 in Database interfaces

Download history 4/week @ 2024-02-18 34/week @ 2024-02-25 5/week @ 2024-03-03 9/week @ 2024-03-10 5/week @ 2024-03-17

53 downloads per month
Used in 5 crates (3 directly)

MIT/Apache

4KB

Toql - A friendly and productive ORM

Tests Current Crates.io Version

Beginner Guide | API documentation

Toql is an ORM for async databases that features

  • Translation between Rust structs and database tables.
  • Can load and modify nested structs.
  • A unique dead simple query language, suitable for web clients.
  • Different table aliases from long and readable to tiny and fast.
  • Prepared statements against SQL injection.
  • Support for raw SQL for full database power.
  • Support for role based access.
  • Highly customizable through user defined parameters, query functions, field handlers, etc.
  • Compile time safety for queries, fields and path names.
  • No unsafe Rust code.
  • Tested on real world scenario.

It currently only supports MySQL. More are coming, promised :)

Installation

Add this to your Cargo.toml:

[dependencies]
toql = {version = "0.4", features = ["serde"]}
toql_mysql_async = "0.4"

Look And Feel

Derive your structs:

#[derive(Toql)]
#[toql(auto_key)]
struct Todo {
    #[toql(key)]
    id: u64,
    what: String,

    #[toql(join)]
    user: User 
}

And do stuff with them:

let toql = ...
let todo = Todo{ ... };

// Insert todo and update its generated id
toql.insert_one(&mut todo, paths!(top)).await?; 

// Compile time checked queries!
let q = query!(Todo, "*, user_id eq ?", &todo.user.id); 

// Typesafe loading
let todos = toql.load_many(q).await?; 

Quick start

Check out the CRUD example.

Contribution

Comments, bug fixes and quality improvements are welcome.

License

Toql is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

Dependencies

~2.2–3MB
~61K SLoC