Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diesel-rs/r2d2-diesel
https://github.com/diesel-rs/r2d2-diesel
database-connector rust sql
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/diesel-rs/r2d2-diesel
- Owner: diesel-rs
- License: mit
- Created: 2015-12-02T23:05:59.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-08-28T21:21:27.000Z (over 6 years ago)
- Last Synced: 2024-10-14T09:17:52.844Z (2 months ago)
- Topics: database-connector, rust, sql
- Language: Rust
- Size: 17.6 KB
- Stars: 101
- Watchers: 10
- Forks: 25
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
THIS CRATE HAS BEEN DEPRECATED, USE THE `r2d2` MODULE IN DIESEL INSTEAD
===r2d2-diesel
===========Provides [r2d2](https://github.com/sfackler/r2d2) support to allow connection pooling with Diesel.
Examples
========The examples creates a connection pool with default settings for a PostgreSQL or
SQLite database running on localhost, then creates a bunch of threads and
acquires a connection from the pool for each thread.Executable versions are in [examples/](examples/) which you can run with
`cargo run --example postgres --features "diesel/postgres"` or
`cargo run --example sqlite --features "diesel/sqlite"`.```rust
extern crate diesel;
extern crate r2d2;
extern crate r2d2_diesel;use std::thread;
use diesel::PgConnection;
use r2d2_diesel::ConnectionManager;fn main() {
let manager = ConnectionManager::::new("postgres://localhost/");
let pool = r2d2::Pool::builder().build(manager).expect("Failed to create pool.");for _ in 0..10i32 {
let pool = pool.clone();
thread::spawn(move || {
let connection = pool.get();assert!(connection.is_ok());
});
}
}
```Using diesel master branch
============================If you want to use diesel master's branch with r2d2-diesel you have to add the
following section in your Cargo.toml file. If you're using a workspace, this
needs to be in the Cargo.toml at the root of the workspace.```toml
[patch.crates-io]
diesel = { git = "https://github.com/diesel-rs/diesel.git" }
diesel_infer_schema = { git = "https://github.com/diesel-rs/diesel.git" }
diesel_codegen = { git = "https://github.com/diesel-rs/diesel.git" }
```