pqparser

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2019 License: BSD-2-Clause Imports: 10 Imported by: 0

README

pqparser

A helper library to support libpq style connection strings for go-pg

Why?

go-pg does have a very limited support for URI style DSN's. The goal of this library is, to support the full feature set of libpq's connection strings.

Usage

package main
import (
	"gitlab.com/tbe/pqparser"
	"github.com/go-pg/pg"
)	
func main() {
	options,err := pqparser.Parse("postgres://%2Fvar%2Flib%2Fpostgresql/dbname")
	if err != nil {
		panic(err)
	}
	
	db := pg.Connect(options)
	...
}

For full documentation about the behavior of Parse, see the libpq documenation

Limitations

In difference to libpq, we use a TCP connection to localhost if no hostname is given. libpq has a default socket path, but we don't know where the socket could be found.

Currently, there are a few features that are not implemented.

keepalive* settings

As go-pq does not have support for keepalive settings, we ignore these parameters.

sslcompression

I'm not sure if it is possible to implement this without dark hacks.

requirepeer

This may be implemented later. We could implement this by overriding the Dialer function.

krbsrvname and gsslib

There is no support for this authentication methods in go-pg.

service

Could be implemented later. PR's welcome

sslmode

Expect verify-full, all sslmodes skip the host verification at the moment.

sslrootcert and sslcrl

Should be simple to implement, but the work is not done yet

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(connstr string) (*pg.Options, error)

Parse a connection string or URI. The connection string is parsed as defined in the libpq documentation: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING

The described environment variables are used exactly the same. If a value does not exist, than the corresponding environment variable is taken if it exists.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL