#string-parser #postgresql #connection #uri #host-port #url-scheme #idiosyncratic

bin+lib pg-connection-string

PostgreSQL-compatibly idiosyncratic connection string parsing

2 releases

0.0.2 Oct 24, 2023
0.0.1 Oct 19, 2021

#1479 in Database interfaces

AGPL-3.0-or-later

69KB
2K SLoC

pg-connection-string parses URIs in the ways that psql (and generally, libpq) will accept them. This is a more convenient and robust alternative to crates like uri.

As outlined in the Postgres docs, the general form for a connection URI is:

postgresql://[userspec@][hostspec][/dbname][?paramspec]

where userspec is:

user[:password]

and hostspec is:

[host][:port][,...]

and paramspec is:

name=value[&...]

The URI scheme designator can be either postgresql:// or postgres://. Each of the remaining URI parts is optional.

Dependencies

~1.2–8.5MB
~68K SLoC