Database selection with a user attribute

In this section, we'll explore the seamless process of selecting a database using user attributes, specifically tailored for SQL connectors. When dealing with diverse datasets stored in different databases or schemas based on user distinctions, the ability to dynamically select the appropriate database becomes invaluable. For the sake of illustration, we will be utilizing the PostgreSQL connector.

It's highly recommended as an App-builder to be connected with an account that has the user attributes used that are set. This ensures a smooth and efficient configuration process.

How to configure the database within database selection?

Let's dive into an illustrative example of how to fetch data on a specific database from a Redshift server based on user context. The key to achieving this lies in template-based configuration, specifically manipulating the database field while referencing the user attribute “redshift_db”.

  • Create a new dataset from a connector (Redshift in the example below)

  • During the database selection step, select the option “Several databases through variable”.

  • Write the templating syntax within the field as in the picture below.

More on variable syntaxes in this page.

If you are not connected with a user that has those attributes that are set, you can make the choice to use conditional templating syntax (given in the linked page above).

How to configure the database within SQL query?

  • Create a new dataset from the connector

  • Select a schema

  • Select a table and switch to “Code-mode” by clicking on the option within the interface

In the example below, the data will be fetch on a specific database according the user context, by templating the database within the SQL query (case of BigQuery) and referring to the user attribute “bigquery_schema”.

  • Replace the schema by the syntax to refer the user attribute.

More on variable syntaxes in this page.

If you are not connected with a user that has those attributes that are set, you can make the choice to use conditional templating syntax (given in the linked page above).

Last updated