PostgreSQL driver and toolkit for Go
 
 
 
Go to file
Jonathan Rudenberg 10655944aa Minor docs fixes for large objects 2015-01-02 17:05:51 -05:00
examples Add example of listen/notify support 2014-11-01 10:45:18 -05:00
stdlib Add stdlib test for []byte 2014-10-03 14:52:33 -05:00
.gitignore Rename ConnectionParameters to ConnConfig 2014-05-17 13:38:13 -05:00
CHANGELOG.md Update changelog 2014-12-23 18:19:22 -06:00
LICENSE Add license 2013-07-30 19:05:09 -05:00
README.md Minor docs fixes for large objects 2015-01-02 17:05:51 -05:00
bench_test.go Move to Scan interface 2014-07-05 18:23:19 -05:00
conn.go Implement large object support 2015-01-01 22:01:01 -05:00
conn_config_test.go.example Add TLS to conn_config_test.go.example 2014-07-29 17:41:53 -05:00
conn_pool.go ConnPool no longer creates connections just to release them. 2014-11-12 08:11:33 -06:00
conn_pool_test.go select; is valid in 9.4. This causes the two tests to exec successfully when 2014-11-17 21:21:08 +07:00
conn_test.go support for inserting []time.Time into timestamp[] columns 2014-12-21 13:35:39 +07:00
doc.go Add hstore to docs 2014-09-19 17:38:35 -05:00
example_custom_type_test.go Enhance support for custom types 2014-09-19 15:27:15 -05:00
fastpath.go Implement large object support 2015-01-01 22:01:01 -05:00
helper_test.go Add support for integer, float and text arrays 2014-07-26 15:03:52 -05:00
hstore.go document ParseHstore 2014-09-22 13:22:15 -04:00
hstore_test.go Add tests for NullHstore 2014-09-19 17:34:02 -05:00
large_objects.go Minor docs fixes for large objects 2015-01-02 17:05:51 -05:00
large_objects_test.go Implement large object support 2015-01-01 22:01:01 -05:00
logger.go Trying to reduce memory allocation. logQueryArgs is called even when 2014-11-18 07:53:33 +07:00
messages.go add support for EmptyQueryResponse 2014-09-26 17:14:28 -04:00
msg_reader.go Make MsgReader private 2014-07-12 20:08:17 -05:00
query.go Tweak handling of reading null as raw bytes. 2014-12-23 21:58:48 -06:00
query_test.go Tweak handling of reading null as raw bytes. 2014-12-23 21:58:48 -06:00
sql.go Add QueryArgs 2014-05-21 08:17:24 -05:00
sql_test.go Update github.com/JackC to github.com/jackc 2014-06-21 08:36:20 -05:00
tx.go Tx.QueryRow implemented in terms of Tx.Query 2014-07-14 07:55:20 -05:00
tx_test.go Use database/sql style transaction interface 2014-07-12 07:59:30 -05:00
value_reader.go Tweak handling of reading null as raw bytes. 2014-12-23 21:58:48 -06:00
values.go Add timestamptz[] support 2014-12-23 18:17:39 -06:00
values_test.go Add timestamptz[] support 2014-12-23 18:17:39 -06:00

README.md

pgx

PostgreSQL client library for Go

Description

pgx is a database connection library designed specifically for PostgreSQL. pgx offers an interface similar to database/sql that offers more performance and features than are available with the database/sql interface. It also can run as a database/sql compatible driver.

Native Interface

The pgx native interface is faster than using pgx as a driver for database/sql. The performance improvement ranges from as little as 3% for returning a single value to 30% for returning many rows with multiple columns.

The pgx native interface supports the following extra features:

  • Listen / notify
  • Transaction isolation level control
  • Full TLS connection control
  • Binary format support for custom types (can be much faster)
  • Logging support
  • Configurable connection pool with after connect hooks to do arbitrary connection setup
  • PostgreSQL array to Go slice mapping for integers, floats, and strings
  • Hstore support
  • Large object support

database/sql

Import the github.com/jackc/pgx/stdlib package to use pgx as a driver for database/sql. It is possible to retrieve a pgx connection from database/sql on demand. This allows using the database/sql interface in most places, but using pgx directly when more performance or PostgreSQL specific features are needed.

Documentation

pgx includes extensive documentation in the godoc format. It is viewable online at godoc.org.

Testing

pgx supports multiple connection and authentication types. Setting up a test environment that can test all of them can be cumbersome. In particular, Windows cannot test Unix domain socket connections. Because of this pgx will skip tests for connection types that are not configured.

Normal Test Environment

To setup the normal test environment run the following SQL:

create user pgx_md5 password 'secret';
create database pgx_test;

Connect to database pgx_test and run:

create extension hstore;

Next open connection_settings_test.go.example and make a copy without the .example. If your PostgreSQL server is accepting connections on 127.0.0.1, then you are done.

Connection and Authentication Test Environment

Complete the normal test environment setup and also do the following.

Run the following SQL:

create user pgx_none;
create user pgx_pw password 'secret';

Add the following to your pg_hba.conf:

If you are developing on Unix with domain socket connections:

local  pgx_test  pgx_none  trust
local  pgx_test  pgx_pw    password
local  pgx_test  pgx_md5   md5

If you are developing on Windows with TCP connections:

host  pgx_test  pgx_none  127.0.0.1/32 trust
host  pgx_test  pgx_pw    127.0.0.1/32 password
host  pgx_test  pgx_md5   127.0.0.1/32 md5

Version Policy

pgx follows semantic versioning for the documented public API. master branch tracks the latest stable branch (v2). Consider using import "gopkg.in/jackc/pgx.v2" to lock to the v2 branch or use a vendoring tool such as godep.