Skip to content

PostgreSQL

BInbox signs in to PostgreSQL with a user name and a password, over TLS 1.2 or higher, and reads with that user’s own privileges. It shows only the schemas and tables the user may read.

On New connection, choose PostgreSQL.

Field What to enter
Host The server’s host name or address, such as db.example.com.
Port 5432 unless your server uses another port. You may leave it empty.
Database The database to read.
Certificate authority Optional. Paste the authority’s certificate in PEM only when a public authority did not sign the server’s certificate.
How BInbox signs in A service account’s user name and password or key file. This is the only choice.
User name The login you make below, binbox_reader.
Password That user’s password.

Run these statements in psql as a user who may create roles. Replace the text in angle brackets, and use a long random password.

CREATE ROLE binbox_reader LOGIN PASSWORD '<a long random password>';
GRANT CONNECT ON DATABASE <database> TO binbox_reader;
GRANT USAGE ON SCHEMA <schema> TO binbox_reader;
GRANT SELECT ON ALL TABLES IN SCHEMA <schema> TO binbox_reader;
ALTER DEFAULT PRIVILEGES FOR ROLE <table owner> IN SCHEMA <schema>
GRANT SELECT ON TABLES TO binbox_reader;

Repeat the last three statements for each schema BInbox should read. The last statement covers tables made later by the table owner. On a managed service such as Amazon RDS, Google Cloud SQL or Azure Database for PostgreSQL, open the service’s query tool or connect with psql, and run the same statements.

Check the new user before you paste anything into BInbox:

Terminal window
psql "host=<host> port=5432 dbname=<database> user=binbox_reader sslmode=verify-full" -c "select 1"

If the server uses a private certificate authority, add sslrootcert=<file> to the connection string, and paste that file into Certificate authority in BInbox.

On PostgreSQL 12 and later, BInbox asks for every decimal number exactly as the database stores it. It does this for each query alone, inside that query’s read-only transaction, so the setting changes nothing for anyone else who uses the database, a connection pool included. A server can be set to write 15 digits, and then it rounds the last ones off, so BInbox asks for all of them.

A figure in a chart or a table is still shown with the decimals its field is set to show. Where a figure is shown without rounding, or a decimal column is used as a category or a filter, it has its full digits, such as 0.30000000000000004 for 0.1 plus 0.2.

On PostgreSQL 11 and earlier, BInbox reads numbers with the digits the server writes, as it did before. PostgreSQL 11 went out of support in November 2023.

Grant Why BInbox needs it
CONNECT on the database To sign in.
USAGE on each schema to read To list the schemas.
SELECT on each table or view to read To read tables and run queries.

BInbox needs nothing else, so do not make the user a superuser, and do not grant INSERT, UPDATE, DELETE or CREATE.

Choose Test connection in BInbox. The report lists these four permissions, and all four must be Granted:

Permission Granted when
Sign in The user name and password are accepted over TLS.
List the schemas The user may use at least one schema that is not the server’s own.
Read at least one table The user may SELECT from at least one table or view.
Run a query A select 1 runs.
Refuse a write, so SQL an author writes can run (optional) A delete of no rows from the first table the user may read, DELETE FROM <table> WHERE 1 = 0, is refused inside a read-only transaction. BInbox runs every query in such a transaction. Without this, authors still pick tables, but cannot write a dataset’s SQL.

The report also says which PostgreSQL version answered and that the connection used TLS. If Sign in is refused, the user name or password is wrong, or the server does not offer TLS. If List the schemas or Read at least one table is refused, a GRANT above is missing.

An owner or admin opens the Data tab at app.binbox.ai, chooses Connect, then New connection, fills in the fields above, and chooses Test and save. BInbox saves the connection only when the test passes. Connections describes the screen.

Then an author sets up a dataset from one of the connection’s tables or views, as Pick a table describes.