Create a Postgres Data Source
- From the navigation pane, click Data > Data Sources.
- Click Create a Data Source.
- In the New Data Source window, from Select Data Store, select PostgreSQL.
- Enter the Host, Port, and Database name.
- Enter the Data Source Name.
- Optional: Enter a Description to explain the purpose of the Data Source to others.
- Click Next.
-
Specify the credentials for authenticating to Postgres.
Basic authentication is supported by default. IAM credential propagation might also be available if your administrator has enabled it.
IAM-authenticated connections can be used only for executing jobs and workspaces. Other execution types, such as scheduled jobs and Domino endpoints, require basic authentication.
- If you are using basic authentication, click Test Credentials to validate your username and password.
- Click Next (or Skip for Now to configure authentication later).
- Enter the users and organizations who can view and use the Data Source in projects.
- Click Finish Setup.
Alternate way to connect to a Postgres Data Source
This instruction assumes you already have pip installed.- For Python and psycopg2, Domino recommends the psycopg2 library to interact with PostgreSQL databases from Python.
-
Use the following Dockerfile instruction to install psycopg2 in your environment.
-
Set the following as Domino environment variables to store secure information about your PostgreSQL connection.
-
POSTGRES_HOSTHostname where your DB is running. Make sure your PostgreSQL DB and network firewall are configured to accept connections from Domino. -
POSTGRES_USERThe PostgreSQL user you want to authenticate as. -
POSTGRES_PASSWORDThe password for the user chosen previously. See Store Project credentials to learn more about Domino environment variables.
-
-
See the psycopg2 documentation for detailed information about how to use the package. The following is an example to connect to PostgreSQL with
psycopg2where:- You have set up environment variables with the hostname, username, and password.
-
Your user has access to a database named
db1in the target PostgreSQL instance. -
The database contains a table named
metrics.The results object created in the previous example is a Python array of entries from the queried table.
R and RPostgreSQL
- To connect to R and RPostgreSQL, Domino recommends the RPostgreSQL library to interact with PostgreSQL databases from R.
-
Use the following Dockerfile instruction to add RPostgreSQL to your environment.
-
Set up the Domino environment variables to store secure information about your PostgreSQL connection.
-
POSTGRES_HOSTHostname where your DB is running. Make sure your PostgreSQL DB and network firewall are configured to accept connections from Domino. -
POSTGRES_USERThe PostgreSQL user you want to authenticate as. -
POSTGRES_PASSWORDThe password for the user chosen previously. See Store Project credentials to learn more about Domino environment variables.
-
-
See the RPostgreSQL documentation for information about how to use the package. The following is an example for connecting to PostgreSQL with RPostgreSQL where:
- You have set up environment variables with the hostname, username, and password.
-
Your user has access to a database named
db1in the target PostgreSQL instance. -
The database contains a table named
metrics`.
Next steps
- After connecting to your Data Source, learn how to Use Data Sources.
- Share this Data Source with your collaborators.