diff --git a/postgresql/database.go b/postgresql/database.go
index 930853f569c093fa4a991eec386be46f4c060667..2216f9b9d8c4fa0c31c0161b38ce8f6a771489e0 100644
--- a/postgresql/database.go
+++ b/postgresql/database.go
@@ -54,66 +54,6 @@ func newDatabase(settings db.ConnectionURL) (*database, error) {
 	return d, nil
 }
 
-// Open stablishes a new connection with the SQL server.
-func Open(settings db.ConnectionURL) (db.SQLDatabase, error) {
-	d, err := newDatabase(settings)
-	if err != nil {
-		return nil, err
-	}
-	if err := d.Open(settings); err != nil {
-		return nil, err
-	}
-	return d, nil
-}
-
-// NewTx returns a transaction session.
-func NewTx(sqlTx *sql.Tx) (db.SQLTx, error) {
-	d, err := newDatabase(nil)
-	if err != nil {
-		return nil, err
-	}
-
-	// Binding with sqladapter's logic.
-	d.BaseDatabase = sqladapter.NewBaseDatabase(d)
-
-	// Binding with builder.
-	b, err := builder.New(d.BaseDatabase, template)
-	if err != nil {
-		return nil, err
-	}
-	d.SQLBuilder = b
-
-	if err := d.BaseDatabase.BindTx(sqlTx); err != nil {
-		return nil, err
-	}
-
-	newTx := sqladapter.NewTx(d)
-	return &tx{DatabaseTx: newTx}, nil
-}
-
-// New wraps the given *sql.DB session and creates a new db session.
-func New(sess *sql.DB) (db.SQLDatabase, error) {
-	d, err := newDatabase(nil)
-	if err != nil {
-		return nil, err
-	}
-
-	// Binding with sqladapter's logic.
-	d.BaseDatabase = sqladapter.NewBaseDatabase(d)
-
-	// Binding with builder.
-	b, err := builder.New(d.BaseDatabase, template)
-	if err != nil {
-		return nil, err
-	}
-	d.SQLBuilder = b
-
-	if err := d.BaseDatabase.BindSession(sess); err != nil {
-		return nil, err
-	}
-	return d, nil
-}
-
 // ConnectionURL returns this database's ConnectionURL.
 func (d *database) ConnectionURL() db.ConnectionURL {
 	return d.connURL
@@ -206,6 +146,7 @@ func (d *database) CompileStatement(stmt *exql.Statement) string {
 func (d *database) Err(err error) error {
 	if err != nil {
 		s := err.Error()
+		// These errors are not exported so we have to check them by they string value.
 		if strings.Contains(s, `too many clients`) || strings.Contains(s, `remaining connection slots are reserved`) || strings.Contains(s, `too many open`) {
 			return db.ErrTooManyClients
 		}
diff --git a/postgresql/postgresql.go b/postgresql/postgresql.go
index 2db921a24a96a8b549ac1104df433d94f1d42892..2510cedf20313fa269ebd5349f5845b94b0e01bf 100644
--- a/postgresql/postgresql.go
+++ b/postgresql/postgresql.go
@@ -22,7 +22,11 @@
 package postgresql // import "upper.io/db.v2/postgresql"
 
 import (
+	"database/sql"
 	"upper.io/db.v2"
+
+	"upper.io/db.v2/internal/sqladapter"
+	"upper.io/db.v2/sqlbuilder"
 )
 
 const sqlDriver = `postgres`
@@ -37,3 +41,63 @@ func init() {
 		Open:  Open,
 	})
 }
+
+// Open stablishes a new connection with the SQL server.
+func Open(settings db.ConnectionURL) (db.SQLDatabase, error) {
+	d, err := newDatabase(settings)
+	if err != nil {
+		return nil, err
+	}
+	if err := d.Open(settings); err != nil {
+		return nil, err
+	}
+	return d, nil
+}
+
+// NewTx returns a transaction session.
+func NewTx(sqlTx *sql.Tx) (db.SQLTx, error) {
+	d, err := newDatabase(nil)
+	if err != nil {
+		return nil, err
+	}
+
+	// Binding with sqladapter's logic.
+	d.BaseDatabase = sqladapter.NewBaseDatabase(d)
+
+	// Binding with builder.
+	b, err := builder.New(d.BaseDatabase, template)
+	if err != nil {
+		return nil, err
+	}
+	d.SQLBuilder = b
+
+	if err := d.BaseDatabase.BindTx(sqlTx); err != nil {
+		return nil, err
+	}
+
+	newTx := sqladapter.NewTx(d)
+	return &tx{DatabaseTx: newTx}, nil
+}
+
+// New wraps the given *sql.DB session and creates a new db session.
+func New(sess *sql.DB) (db.SQLDatabase, error) {
+	d, err := newDatabase(nil)
+	if err != nil {
+		return nil, err
+	}
+
+	// Binding with sqladapter's logic.
+	d.BaseDatabase = sqladapter.NewBaseDatabase(d)
+
+	// Binding with builder.
+	b, err := builder.New(d.BaseDatabase, template)
+	if err != nil {
+		return nil, err
+	}
+	d.SQLBuilder = b
+
+	if err := d.BaseDatabase.BindSession(sess); err != nil {
+		return nil, err
+	}
+	return d, nil
+}