Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
pawurb committed Oct 9, 2024
1 parent c825c3a commit e56797c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ tokio = { version = "1.40", features = ["full"] }
[[bin]]
name = "pg_extras"
path = "src/main.rs"

[[example]]
name = "db_settings"
path = "examples/db_settings.rs"
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ Alternative versions:

## Installation

In your Cargo.toml

```rust
pg-extras = "0.4"
```bash
cargo add pg-extras
```

`calls` and `outliers` queries require [pg_stat_statements](https://www.postgresql.org/docs/current/pgstatstatements.html) extension.
Expand Down
15 changes: 15 additions & 0 deletions examples/db_settings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use pg_extras::{db_settings, render_table, PgExtrasError};

#[tokio::main]

async fn main() -> Result<(), PgExtrasError> {
std::env::set_var(
"PG_EXTRAS_DATABASE_URL",
"postgres://postgres:secret@localhost:5432/rust-pg-extras-test",
);

let settings = db_settings().await?;
render_table(settings);

Ok(())
}

0 comments on commit e56797c

Please sign in to comment.