https://github.com/njaard/postgres-service
A Rust Crate that parses pg_service.conf files.
https://github.com/njaard/postgres-service
Last synced: 8 months ago
JSON representation
A Rust Crate that parses pg_service.conf files.
- Host: GitHub
- URL: https://github.com/njaard/postgres-service
- Owner: njaard
- License: bsd-2-clause
- Created: 2017-04-21T19:40:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-02-20T18:01:04.000Z (over 1 year ago)
- Last Synced: 2025-01-31T02:15:42.326Z (8 months ago)
- Language: Rust
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Introduction
If you use postgres's [service feature](https://www.postgresql.org/docs/current/static/libpq-pgservice.html)
for configuring your connections, then this is the library for you.This is for use with the [Postgres crate](https://crates.io/crates/postgres).
# Features
* supports [tokio-postgres](https://crates.io/crates/tokio-postgres) (New in 0.19.2)
* ... and regular [postgres](https://crates.io/crates/postgres)
* search in `~/.pg_service.conf`, `$PGSYSCONFDIR/pg_service.conf`, and `/etc/postgresql-common/pg_service.conf`
* Simply generates a [postgres::Config](https://docs.rs/postgres/0.19.2/postgres/config/struct.Config.html)# Example
This example uses the service name `mydb` and overrides
the `user` value, then makes the connection.let conn = postgres_service::load_connect_params("mydb")
.expect("unable to find configuration")
.user("your_user_name")
.connect(postgres::NoTls)
.expect("unable to connect");