Top.Mail.Ru
Script Example
CTRL+K

Script Example

In this article
  • Script Example

Suppose you need to load new data from a database into the system and generate a report based on the retrieved information. To accomplish this, you can create a script consisting of four blocks:

  • Scheduler to run the script at specific time
  • SQL Query to delete the existing data
  • SQL Query to retrieve new data
  • Insert rows to insert new data into a table in the Data Model

Script example

  1. In the first block, Scheduler, set the schedule for the script execution. Scheduler
  2. In the second block, specify from where the data should be deleted, for example, from the table into which you are going to insert the retrieved data. Enter the SQL query. Deleting data is necessary to avoid duplication each time the script runs. Second block When accessing a different database, you can use the following SQL query:
    truncate table if exists `db_name`.`table_name`
    
  3. In the third block, use an SQL query to select new data and specify the source. You can enter the table name manually or click the Table field to select it from the list. List of tables When working with a PostgreSQL connection, you can use this SQL query:
    select * from public.table_name
    
  4. In the fourth block, select the table into which you want to insert new data or create a new one. Fourth block Use mapping to specify from which database column the value should be taken. You can select the appropriate mapping fields either by clicking on the target table column or using the mapping field tree in the panel that opens. When you hover over a column, a tooltip with the data type appears. Mapping example
Important

The block configuration is considered complete after it has been tested. Therefore, mapping values from the previous block become available only after the block has been tested.

Once executed, the script loads the required information from the selected database into the system.

Was the article helpful?

Yes
No
Previous
Running a Script
We use cookies to improve our website for you.