Transferring data to SQL Database

This guide explains how to transfer data to SQL Database to store and further process information.

Introduction

Use the SQL Database Destination to transfer data to an SQL Database. Adverity supports the following engine types:

  • Amazon Redshift

  • Microsoft SQL Server

  • MySQL

  • Oracle

  • Postgres

  • SAP HANA

  • Snowflake

Concept

SQL Database is an Active Destination. After you set SQL Database as the Destination of a Datastream, data is transferred to SQL Database each time data is fetched for the Datastream. For more information, see Destination types.

You can assign multiple Destinations to a Datastream. For more information on possible limitations, see Assigning multiple Destinations to a Datastream.

Prerequisites

Before you complete the procedure in this guide, perform all of the following actions:

Procedure

To transfer data from a Datastream to SQL Database, follow these steps:

  1. Add SQL Database as a Destination to the Workspace which contains the Datastream or to one of its parent Workspaces.

  2. Assign the SQL Database Destination to the Datastream.

  3. Configure transfer settings.

Adding SQL Database as a Destination

To add SQL Database as a Destination to a Workspace, follow these steps:

  1. Click the Transfer element and select the Workspace you work with in Connect, Enrich & Transfer.

  1. Click + Add.

  2. Click SQL Database.

  1. In the Configuration page, fill in the following fields:

    Name

    (Optional) Rename the Destination.

    Engine type

    Select the SQL engine type from the drop-down list.

    Hostname

    Specify the URL of the SQL Database. If you use a port other than the default setting for this SQL Database, specify the port in the format hostname:port.

    Database

    Specify the name of the database where to transfer the data.

    Username

    Enter the username for SQL Database Destination.

    Password

    Enter the password for SQL Database Destination.

    For more information on advanced configuration settings, see SQL Database Destination reference.

  1. Click Create.

Assigning SQL Database as a Destination

To assign the SQL Database Destination to a Datastream, follow these steps:

  1. Click the Connect element and select the Workspace you work with in Connect, Enrich & Transfer.

  1. Select the chosen Datastream.

  1. In the Destinations section, click + Add Destination.

  2. Click Assign Existing Destinations.

  1. Select the SQL Database checkbox in the list.

  2. Click Save.

Configuring transfer settings

To configure transfer settings, follow these steps:

  1. Click the Connect element and select the Workspace you work with in Connect, Enrich & Transfer.

  1. Select the chosen Datastream.

  1. In the Destinations section, find the SQL Database Destination in the list, and click on the right.

  2. Click Destination Settings.

  1. Fill in the following fields:

    Table name

    Specify the target table in the Destination where to transfer data from the Datastream. The name can contain alphanumeric characters and underscores. For example, target_table. To specify a schema, use the syntax schemaName.tableName.

    By default, Adverity saves data from each Datastream in a different table named {datastream_type}_{datastream_id} (for example, mailgun_83).

    You can specify the same target table for several Datastreams. If a column is shared between Datastreams, Adverity performs a full outer join and concatenates values. If a column is not shared between Datastreams, Adverity writes null values in the relevant cells.

    Use placeholders to create unique, dynamic table names in the Destination. Use the following placeholders:

    Placeholder

    Description

    {datastream_id}

    The Datastream ID.

    {datastream_type}

    The Datastream Type.

    {extract_id}

    The Data Extract ID.

    {meta[*]}

    Replace * with a metadata placeholder to use metadata in the table name. For example, {meta[datastream_URI]} uses the Datastream URI as the table name. For more information on metadata and placeholders, see Using placeholders.

    {name}

    The automatically generated filename of the Data Extract.

    {scheduled_day}

    The day from the start date of a date range for a scheduled data fetch.

    {scheduled_month}

    The month from the start date of a date range for a scheduled data fetch.

    {scheduled_year}

    The year from the start date of a date range for a scheduled data fetch.

    Truncate

    Select this checkbox to delete all rows from the relevant table in the Destination before transferring the latest Data Extract.

    Datastream

    Select this checkbox to overwrite data in the target table if both of these conditions are satisfied:

    • The data was previously transferred from this Datastream. Data transferred from other Datastreams is not overwritten.

    • The date ranges of the existing and the new data set overlap. Adverity overwrites existing data in the target table if it refers to the same dates as the new data from the Datastream.

    For example, if the existing data in the target table refers to 10 January 2022 - 14 January 2022, and the data from the Datastream refers to 13 January 2022 - 17 January 2022, then Adverity overwrites data in the target table for 13 January 2022 and 14 January 2022.

    If you select this checkbox, specify the column in your Data Extract that contains the dates in Date Range.

    Date Range

    Select the column in your Data Extract that contains the dates.

    Filename

    Select this checkbox to overwrite the relevant data in the Destination if a Data Extract with the same filename already exists in the Destination.

    Key Columns

    Select this checkbox to overwrite data in the Destination based on the key columns defined in the Schema Mapping of the Datastream. Adverity executes this overwrite option after all the other overwrite options. When you select this checkbox, the configuration to overwrite data based on dates does not have an effect.

  2. Click Save.