# Ingesting data into Cognite RAW

Cognite RAW does not have a predefined database or table setup, so you need to create the database table in CDF and a foreign table for the PostgreSQL gateway before setting up the connection in your ETL tool.

In this article:

# Step 1: Create Cognite RAW database table

  1. Sign in to Cognite Data Fusion (opens new window) as an admin.

  2. In the top menu, select Integrate > Browse staged data.

  3. Under Databases, click Create Database and enter a Unique name.

  4. Select Create.

  5. Under Databases, click Create Table and enter a Unique name.

  6. Select Create.

    Create database in CDF

# Step 2: Connect to PostgreSQL gateway

Connect to the PostgreSQL gateway using a standard PostgreSQL server tool. The example below uses pgAdmin.

  1. Open pgAdmin (opens new window).

  2. Click Add New Server and enter a name on the General tab.

  3. On the Connection tab,

    1. In the Host name/address field, enter https://skywarp.{cluster}.cognite.ai where cluster is where your CDF instance is installed.

    2. In the Maintenance database and Username fields, enter the username returned by the PostgreSQL gateway when you generated the user credentials.

    3. In the Password field, enter the password returned by the PostgreSQL gateway when you generated the user credentials.

  4. Click Save to connect to the PostgreSQL gateway server.

    Set up pgAdmin

# Step 3: Create foreign table for RAW table in PostgreSQL gateway

  1. Under Servers, open the PostgreSQL gateway server.

  2. Under Schemas, select Foreign Tables, then right-click and select Create > Foreign Table.

  3. In the Create-Foreign table window:

    1. On the General tab, enter a Name.

    2. On the Definitions tab, select raw_server in the Foreign server list.

    3. On the Columns tab, click the plus sign to create the database table columns you want to ingest data into.

    4. On the Options tab:

      1. In the Option field, enter primary_key (in small letters only) in the first row.

      2. In the Value field, select one of the columns you created in step 3. The values in this column must be unique and not contain nulls.

      3. In the Option field, enter database in the second row.

      4. In the Value field, enter the database name exactly as given in the database you created in CDF RAW.

      5. In the Option field, enter table in the third row.

      6. In the Value field, enter a table name exactly as given in the table you created in CDF RAW.

      pgAdmin values for Foreign table

    5. Click Save and verify that the table you created is listed under Foreign Tables in the sidebar of the PostgreSQL server.

      pgAdmin Foreign table

# Step 4: Complete the connection in ETL

  1. Verify that the table you created above is available as a foreign table in your ETL tool and configure your ETL pipeline between the source system and Cognite RAW.
Last Updated: 6/1/2021, 9:48:27 AM