Connect GX Cloud to PostgreSQL
Prerequisites
-
You have a GX Cloud account with Admin or Editor permissions.
-
You have a PostgreSQL database, schema, and table.
-
Optional. To improve data security, GX recommends creating a separate PostgreSQL user for your GX Cloud connection.
-
Optional. pgAdmin.
Optional. Create a separate PostgreSQL user
-
In pgAdmin, select a database.
-
Click Tools > Query Tool.
-
Paste the following code into the Query pane to create and assign the
gx_role
role and allow GX Cloud to access allpublic
schemas and tables on a specific database.pgAdmin-- Create and assign the gx_role role and allow GX Cloud
-- to access all public schemas and tables on a specific database
CREATE ROLE gx_role WITH LOGIN PASSWORD '<your_password>';
GRANT CONNECT ON DATABASE <your_database> TO gx_role;
GRANT USAGE ON SCHEMA public TO gx_role;
GRANT SELECT ON ALL TABLES in SCHEMA public TO gx_role;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO gx_role- Replace
<your_password>
and<your_database>
with your own values. ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO gx_role;
is optional and gives thegx_role
user access to all future tables in the defined schema.
- Replace
-
Click Execute/Refresh.
Connect to a PostgreSQL Data Source and add a Data Asset
-
In GX Cloud, click Data Assets > New Data Asset > New Data Source > PostgreSQL.
-
Enter a meaningful name for the Data Source in the Data Source name field.
-
Enter a connection string in the Connection string field. The connection string format is:
PostgreSQL connection stringpostgresql+psycopg2://YourUserName:YourPassword@YourHostName:5432/YourDatabaseName
If you created a separate PostgreSQL user for your GX Cloud connection as recommended above, use those credentials in the connection string.
-
Click Connect.
-
Select one or more tables to import as Data Assets.
-
Click Add x Asset(s).
-
Add an Expectation. See Add an Expectation.