#database-schema #orm #sql-database #sql-query #sql #compile-time

diesel-dynamic-schema

A safe, extensible ORM and Query Builder for PostgreSQL, SQLite, and MySQL

5 releases

0.2.2 May 31, 2024
0.2.1 May 26, 2023
0.2.0 Aug 29, 2022
0.2.0-rc.1 Jul 22, 2022
0.2.0-rc.0 Apr 22, 2022

#1988 in Database interfaces

Download history 809/week @ 2024-07-22 916/week @ 2024-07-29 618/week @ 2024-08-05 792/week @ 2024-08-12 661/week @ 2024-08-19 723/week @ 2024-08-26 854/week @ 2024-09-02 925/week @ 2024-09-09 1289/week @ 2024-09-16 896/week @ 2024-09-23 574/week @ 2024-09-30 706/week @ 2024-10-07 783/week @ 2024-10-14 870/week @ 2024-10-21 754/week @ 2024-10-28 1029/week @ 2024-11-04

3,463 downloads per month
Used in diesel-oci

MIT/Apache

2MB
36K SLoC

Query schemas not known at compile time with Diesel

Build Status Gitter

API Documentation: latest release

Diesel is built to provide strong compile time guarantees that your queries are valid. To do this, it needs to represent your schema at compile time. However, there are some times where you don't actually know the schema you're interacting with until runtime.

This crate provides tools to work with those cases, while still being able to use Diesel's query builder. Keep in mind that many compile time guarantees are lost. We cannot verify that the tables/columns you ask for actually exist, or that the types you state are correct.

Getting Started

The main function used by this crate is table. Note that you must always provide an explicit select clause when using this crate.

use diesel_dynamic_schema::table;

let users = table("users");
let id = users.column::<Integer, _>("id");
let name = users.column::<Text, _>("name");

users.select((id, name))
    .filter(name.eq("Sean"))
    .first(&conn)

Code of conduct

Anyone who interacts with Diesel in any space, including but not limited to this GitHub repository, must follow our code of conduct.

License

Licensed under either of these:

Contributing

Unless you explicitly state otherwise, any contribution you intentionally submit for inclusion in the work, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.

Dependencies

~0.7–4MB
~85K SLoC