11 releases
0.19.4 | Feb 20, 2024 |
---|---|
0.19.3 | Jul 7, 2022 |
0.19.2 | Mar 15, 2022 |
0.19.1 | Dec 15, 2021 |
0.1.2 | Jun 15, 2017 |
#2128 in Database interfaces
75 downloads per month
6KB
59 lines
Parse Postgres service configuration files
Postgres service files are configuration files that contain connection parameters
Example
postgres_service::load_connect_params("mydb")
.expect("reading postgres service")
.user("username") // optionally override the username
.connect(postgres::NoTls)
.expect("connecting to postgres");
Introduction
If you use postgres's service feature for configuring your connections, then this is the library for you.
This is for use with the Postgres crate.
Features
- supports tokio-postgres (New in 0.19.2)
- ... and regular postgres
- search in
~/.pg_service.conf
,$PGSYSCONFDIR/pg_service.conf
, and/etc/postgresql-common/pg_service.conf
- Simply generates a postgres::Config
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");
Dependencies
~9–19MB
~265K SLoC