sync_db_pools ![ci.svg] ![crates.io] ![docs.svg]

This crate provides traits, utilities, and a procedural macro for configuring and accessing database connection pools in Rocket. This implementation is backed by [r2d2] and exposes connections through request guards.

Usage

First, enable the feature corresponding to your database type:

toml [dependencies.rocket_sync_db_pools] version = "0.1.0-rc.2" features = ["diesel_sqlite_pool"]

A full list of supported databases and their associated feature names is available in the [crate docs]. In whichever configuration source you choose, configure a databases dictionary with a key for each database, here sqlite_logs in a TOML source:

toml [default.databases] sqlite_logs = { url = "/path/to/database.sqlite" }

In your application's source code:

```rust

[macro_use] extern crate rocket;

use rocketsyncdb_pools::{database, diesel};

[database("sqlite_logs")]

struct LogsDbConn(diesel::SqliteConnection);

[get("/logs/")]

async fn getlogs(conn: LogsDbConn, id: usize) -> Result { conn.run(|c| Logs::byid(c, id)).await }

[launch]

fn rocket() -> _ { rocket::build().attach(LogsDbConn::fairing()) } ```

See the [crate docs] for full details.