Go to file
Hector Rivas Gandara 3d613208bc
Use and respect the passfile connection parameter (#1129)
* Use and respect the passfile connection parameter

The postgres documentation[1] regarding the password file, states
that:

password file to use can be specified using the connection parameter
passfile or the environment variable PGPASSFILE.

The current implementation of lib/pq only respects the environment
variable PGPASSFILE. This is not correct, but also limiting, as
the PGPASSFILE is global and we might want to use different files
for different clients in the same program.

Fixing that is easy, by just checking the parameter passfile first,
and if not, pull the value from PGPASSFILE.

This also moves the parsing of PGPASSFILE to `parseEnviron`.
Now the connection only checks the parameter passfile, that
is populated by `parseEnviron`.

[1] https://www.postgresql.org/docs/current/libpq-pgpass.html
2023-07-07 11:57:34 -04:00
.github/workflows update workflows (#1124) 2023-04-28 23:32:47 +10:00
auth/kerberos update goimports formatting for go1.17 2021-09-01 19:14:16 -07:00
certs mv certs Makefile to certs dir and add explanation 2021-09-01 19:34:21 -07:00
example/listen Add golint, make it pass cleanly, fix some docs 2017-10-22 22:12:46 +03:00
hstore Fixed typos 2019-07-20 06:54:41 +02:00
oid update goimports formatting for go1.17 2021-09-01 19:14:16 -07:00
scram Fixed typos 2019-07-20 06:54:41 +02:00
.gitignore feature: inbuilt support for scanner and valuer in pq.Array for int32/float32/[]byte slices 2020-11-30 22:16:21 +05:30
LICENSE.md Add more accurate copyright clause 2013-06-06 23:14:07 -07:00
README.md Clarify maintenance mode 2021-09-01 16:08:39 -07:00
TESTS.md Add more instructions for running tests (#750) 2018-05-23 13:54:26 -04:00
array.go fix possible integer truncation 2021-09-09 09:15:17 +03:00
array_test.go feature: inbuilt support for scanner and valuer in pq.Array for int32/float32/[]byte slices 2020-11-30 22:16:21 +05:30
bench_test.go Remove go build tags < 1.9 2018-08-25 19:31:48 -04:00
buf.go Update buf.go 2019-07-02 18:50:13 +02:00
buf_test.go Reduce writeBuf.string run-time by 87.68% 2019-07-01 16:30:59 +02:00
conn.go Use and respect the passfile connection parameter (#1129) 2023-07-07 11:57:34 -04:00
conn_go18.go issue 1062: Keep track of (context cancelled) error on connection, and make rows.Next return it (#1064) 2021-11-09 07:06:35 +11:00
conn_go19.go Add support for NamedValueChecker interface (#1125) 2023-05-03 18:09:34 -05:00
conn_go19_test.go Add support for NamedValueChecker interface (#1125) 2023-05-03 18:09:34 -05:00
conn_go115.go add version check for go 1.15 (#1123) 2023-04-26 14:34:24 +10:00
conn_test.go Use and respect the passfile connection parameter (#1129) 2023-07-07 11:57:34 -04:00
connector.go feat: change the connector dialer 2022-05-10 14:24:22 +02:00
connector_example_test.go update goimports formatting for go1.17 2021-09-01 19:14:16 -07:00
connector_test.go Use and respect the passfile connection parameter (#1129) 2023-07-07 11:57:34 -04:00
copy.go Improved the performance of CopyIn and CopyInSchema and added BufferQuoteIdentifier (#1100) 2023-01-25 09:56:06 +11:00
copy_test.go Improved the performance of CopyIn and CopyInSchema and added BufferQuoteIdentifier (#1100) 2023-01-25 09:56:06 +11:00
doc.go use krbsrvname for GSS auth; improve GSS docs 2020-07-27 13:55:44 -06:00
encode.go Added code that accounts for the 'Z' timezone separator in the ParseTimestamp func. (#1073) 2022-04-13 11:12:02 +10:00
encode_test.go Added code that accounts for the 'Z' timezone separator in the ParseTimestamp func. (#1073) 2022-04-13 11:12:02 +10:00
error.go Use pointer receiver on pq.Error.Error() 2022-05-25 12:15:30 -07:00
go.mod Move Kerberos implementation to its own module 2020-05-29 14:39:01 -04:00
go18_test.go error: add SQLState 2022-05-06 18:13:29 +02:00
go19_test.go update goimports formatting for go1.17 2021-09-01 19:14:16 -07:00
issues_test.go conn: Implement driver.Validator, SessionResetter for cancelation 2023-04-14 03:37:37 -04:00
krb.go gss linting 2020-06-08 13:51:27 -06:00
notice.go update goimports formatting for go1.17 2021-09-01 19:14:16 -07:00
notice_example_test.go update goimports formatting for go1.17 2021-09-01 19:14:16 -07:00
notice_test.go update goimports formatting for go1.17 2021-09-01 19:14:16 -07:00
notify.go Add NotificationConnector and methods 2020-05-03 16:17:58 -04:00
notify_test.go Add NotificationConnector and methods 2020-05-03 16:17:58 -04:00
rows.go Add ColumnType support 2017-09-13 09:06:41 -07:00
rows_test.go Remove go build tags < 1.9 2018-08-25 19:31:48 -04:00
ssl.go Set SNI for TSL connections 2022-08-30 22:52:51 +03:00
ssl_permissions.go adds support for kubernetes mounted private keys 2022-05-11 17:40:23 +00:00
ssl_permissions_test.go adds support for kubernetes mounted private keys 2022-05-11 17:40:23 +00:00
ssl_test.go update workflows (#1124) 2023-04-28 23:32:47 +10:00
ssl_windows.go update goimports formatting for go1.17 2021-09-01 19:14:16 -07:00
url.go Support inline SSL certificates 2021-02-12 11:49:11 +01:00
url_test.go Support inline SSL certificates 2021-02-12 11:49:11 +01:00
user_other.go update goimports formatting for go1.17 2021-09-01 19:14:16 -07:00
user_posix.go Fix android build 2021-10-13 15:51:25 +08:00
user_windows.go Fallback to USER env var if user.Current failed 2015-01-09 12:09:49 +01:00
uuid.go Validate incoming binary UUID 2016-12-31 16:29:36 +00:00
uuid_test.go Fix some linting issues 2017-08-08 11:42:56 -07:00

README.md

pq - A pure Go postgres driver for Go's database/sql package

GoDoc

Install

go get github.com/lib/pq

Features

  • SSL
  • Handles bad connections for database/sql
  • Scan time.Time correctly (i.e. timestamp[tz], time[tz], date)
  • Scan binary blobs correctly (i.e. bytea)
  • Package for hstore support
  • COPY FROM support
  • pq.ParseURL for converting urls to connection strings for sql.Open.
  • Many libpq compatible environment variables
  • Unix socket support
  • Notifications: LISTEN/NOTIFY
  • pgpass support
  • GSS (Kerberos) auth

Tests

go test is used for testing. See TESTS.md for more details.

Status

This package is currently in maintenance mode, which means:

  1. It generally does not accept new features.
  2. It does accept bug fixes and version compatability changes provided by the community.
  3. Maintainers usually do not resolve reported issues.
  4. Community members are encouraged to help each other with reported issues.

For users that require new features or reliable resolution of reported bugs, we recommend using pgx which is under active development.