Skip to content

concertgenetics/pgpass.net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pgpass.Net

This is a simple library that builds Postgresql connection strings using your pgpass.conf file.

Features

  • connection string caching
  • PGPASSFILE environment variable support
  • custom connection string template support

Installation

You can install the NuGet package using the package manager console:

PM> Install-Package Pgpass.Net

Basic Usage

var pgpass = new Pgpass("localhost:5432");
var connString = pgpass.GetConnectionString("mydatabase", "myuser");

Advanced Usage

Example 1

var config = new PgpassConfig
{
    UseStaticCache = false,
    IgnoreBadConfigLines = true,
    PathEnvironmentVariable = "PGPASSFILE_PROD",
    DefaultConnectionStringTemplate =
        "Server={0};Port={1};Database={2};User={3};Password={4};Timeout=1000;"
};
var pgpass = new Pgpass("localhost:5432", config);
var connString = pgpass.GetConnectionString("mydatabase", "myuser");

Example 2

var pgpass = new Pgpass("localhost:5432", @"c:\path\to\pgpass.conf");
var connString = pgpass.GetConnectionString("mydatabase", "myuser",
    "Server={0};Port={1};Database={2};User={3};Password={4};Timeout=1000;");

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages