Skip to content

Commit

Permalink
Fix #137, unix socket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-chavez committed May 28, 2018
1 parent 625a0b2 commit b11f9ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ You can rename the columns by prefixing them with an alias followed by the colon
.. code-block:: http
GET /people?select=fullName:full_name,birthDate:birth_date HTTP/1.1
[
{"fullName": "John Doe", "birthDate": "04/25/1988"},
{"fullName": "Jane Doe", "birthDate": "01/12/1998"}
Expand All @@ -155,6 +156,7 @@ Casting the columns is possible by suffixing them with the double colon ``::`` p
.. code-block:: http
GET /people?select=full_name,salary::text HTTP/1.1
[
{"fullName": "John Doe", "salary": "90000.00"},
{"fullName": "Jane Doe", "salary": "120000.00"}
Expand Down
2 changes: 2 additions & 0 deletions install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ role-claim-key String .role
db-uri
The standard connection PostgreSQL `URI format <https://www.postgresql.org/docs/current/static/libpq-connect.html#AEN45347>`_. Symbols and unusual characters in the password or other fields should be percent encoded to avoid a parse error. If enforcing an SSL connection to the database is required you can use `sslmode <https://www.postgresql.org/docs/9.1/static/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS>`_ in the URI, for example ``postgres://user:pass@host:5432/dbname?sslmode=require``.

When running PostgREST on the same machine as PostgreSQL, it is also possible to connect to the database using a `Unix socket <https://en.wikipedia.org/wiki/Unix_domain_socket>`_ and the `Peer Authentication method <http://www.postgresql.org/docs/current/static/auth-methods.html#AUTH-PEER>`_ as an alternative to TCP/IP communication and authentication with a password, this also grants higher performance. According to the documentation on the `libpq connection string <https://www.postgresql.org/docs/10/static/libpq-connect.html#LIBPQ-CONNSTRING>`_ the empty host resolves to the Unix socket and the password can be omitted in this case, so the ``db-uri`` would be reduced to ``postgres://user@/dbname``.

On older systems like Centos 6, with older versions of libpq, a different db-uri syntax has to be used. In this case the URI is a string of space separated key-value pairs (key=value), so the example above would be :code:`"host=host user=user port=5432 dbname=dbname password=pass"`.
db-schema
The database schema to expose to REST clients. Tables, views and stored procedures in this schema will get API endpoints.
Expand Down

0 comments on commit b11f9ef

Please sign in to comment.