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

#755 in Database interfaces

Download history 62/week @ 2024-02-14 81/week @ 2024-02-21 24/week @ 2024-02-28 4/week @ 2024-03-06 2/week @ 2024-03-13 3/week @ 2024-03-27 6/week @ 2024-04-03

75 downloads per month

BSD-2-Clause

6KB
59 lines

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");

lib.rs:

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");

Dependencies

~9–19MB
~329K SLoC