chore: add example to readme

This commit is contained in:
Dmitriy Pleshevskiy 2021-10-22 00:54:47 +03:00
parent f3ab9f4e46
commit 877b312b34
2 changed files with 38 additions and 2 deletions

View file

@ -29,7 +29,23 @@ In stable rust channel you can use only connection interface, but if you use nig
## Usage
See examples directory.
```rust
fn main() -> Result<(), Box<dyn std::error::Error>> {
// create pool to our database
let pool = create_postgres_pool();
// initialize persistence
let persistence = ood_persistence::r2d2_postgres::new(&pool);
// get connection to database
let mut conn = persistence.get_connection()?;
// we can query something
let res: i32 = conn.inner().query_one("select 1", &[])?.get(0);
assert_eq!(res, 1);
Ok(())
}
```
See examples directory for more information.
## Contributors

View file

@ -25,7 +25,27 @@
//!
//! ## Usage
//!
//! See examples directory.
//! ```rust
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // create pool to our database
//! let pool = create_postgres_pool();
//! // initialize persistence
//! let persistence = ood_persistence::r2d2_postgres::new(&pool);
//! // get connection to database
//! let mut conn = persistence.get_connection()?;
//! // we can query something
//! let res: i32 = conn.inner().query_one("select 1", &[])?.get(0);
//! assert_eq!(res, 1);
//!
//! Ok(())
//! }
//! ```
//!
//! See examples directory for more information.
//!
//! ## Contributors
//!
//! [pleshevskiy](https://github.com/pleshevskiy) (Dmitriy Pleshevskiy) creator, maintainer.
//!
#![forbid(unsafe_code, non_ascii_idents)]
#![deny(clippy::pedantic)]