Database selection with a user attribute
Last updated
Was this helpful?
Last updated
Was this helpful?
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.
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.
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 .
More on variable syntaxes in this .