# Data connection settings

After you select the connector type, you configure:

* Where to find the source data
* Where to write the data generation output

## Source database connection <a href="#workspace-config-source-database" id="workspace-config-source-database"></a>

For data connectors that connect to a database, the **Source Settings** section provides connection information for the source database.

You cannot change the source data configuration for a [child workspace](https://docs.tonic.ai/app/workspace/managing-workspaces/workspaces-inheritance).&#x20;

For information about the source connection fields for a specific data connector, go to the workspace configuration topic for that [connector type](https://docs.tonic.ai/app/setting-up-your-database/data-connector-summary).

## Upsert configuration <a href="#workspace-config-connection-upsert" id="workspace-config-connection-upsert"></a>

For data connectors that support upsert, the workspace configuration includes an **Upsert** section to allow you to enable and configure upsert. Upsert adds and updates rows in the destination database, but keeps all other existing rows intact.&#x20;

If you enable upsert, then you cannot write output to a container repository. You must write the output to a destination database.

For more information, go to [workspace-config-upsert](https://docs.tonic.ai/app/workspace/managing-workspaces/workspace-configuration-settings/workspace-config-upsert "mention").

## Destination data location <a href="#workspace-config-destination-data" id="workspace-config-destination-data"></a>

For data connectors that connect to a database, the **Destination Settings** section provides information about where and how Structural writes the output data from data generation.

Depending on the data connector type, you might be able to write to either:

* Destination database - Writes the output data to a destination database on a database server.
* Container repository - Writes the output data to a data volume in a container repository.

### Destination database <a href="#workspace-config-connection-source-destination" id="workspace-config-connection-source-destination"></a>

When you write the output to a destination database, the destination database must be of the same type as the source database.

Structural does not create the destination database. It must exist before you generate data.

In **Destination Settings**, you provide the connection information for the destination database. For information about the destination database connection fields for a specific data connector, go to the workspace configuration topic for that [connector type](https://docs.tonic.ai/app/setting-up-your-database/data-connector-summary).

If available, the **Copy Settings from Source** allows you to copy the source connection details to the destination database, if both databases are in the same location. Structural does not copy the connection password.

### Container repository <a href="#workspace-connection-other-config-containers" id="workspace-connection-other-config-containers"></a>

Some data connectors allow you to write the transformed data to a data volume in a container repository instead of to a database server.

For more information, go to [workspace-config-write-to-container-artifacts](https://docs.tonic.ai/app/workspace/managing-workspaces/workspace-configuration-settings/workspace-config-write-to-container-artifacts "mention").

## Testing database connections <a href="#workspace-config-connection-testing" id="workspace-config-connection-testing"></a>

When you provide connection details for a database server, Structural provides a **Test Connection** button to test the connection. We strongly recommend that you test your database connections.

Structural is currently migrating its data connectors from the legacy connection test to a newer suite of connection tests.

### Legacy connection test

**Used by:** Connectors other than PostgreSQL

The legacy connection test verifies whether Structural is able to connect to the database server.

For some data connectors, the legacy connection test also checks whether the database user has sufficient permissions to perform the required Structural tasks.

When you run the legacy connection test, Structural indicates whether the test was successful.

### New connection test suite

**Used by:** PostgreSQL

For the new connection test suite, the exact tests vary based on the data connector and the connection role, such as source or destination.

At a high level, the new tests can include:

* **Configuration -** Is the connection configuration valid?
* **Connectivity -** Can Structural connect to the server?
* **Schema queries -** Can Structural retrieve the data schema?
* **Data queries -** Can Structural retrieve the data?
* **Data generation -** Can Structural start and run a data generation job? Can Structural write generated data?

When you run the new connection test suite, Structural:

* Lists the tests that it ran.
* Indicates whether each test was successful.
* For failed tests, the results:
  * Indicate whether the failure is fatal, a warning, or informational.\
    \
    Fatal issues must be resolved. Other types of failures might not block functionality, but might have unexpected side effects.
  * When possible, provide a hint as to how to resolve the failure.

### Configuring timeouts for the connection tests

To configure the timeouts for the connection tests, set the following [environment settings](https://docs.tonic.ai/app/admin/environment-variables-setting). You can set these settings from the **Environment Settings** tab on **Structural Settings**.

* `TONIC_TEST_CONNECTION_TIMEOUT_IN_SECONDS` - Used by both the legacy and the new connection tests. The number of seconds before a general connectivity test times out. By default, the connection test times out after 15 seconds.
* `TONIC_DATASOURCE_TEST_TIMEOUT_SECONDS` - Used by the new connection tests only. The number of seconds before an individual test times out. By default, the test times out after 300 seconds.
* `TONIC_DATASOURCE_TEST_SUITE_TIMEOUT_SECONDS` - Used by the new connection tests only. The number of seconds before a connection test suite times out. By default, the suite of tests times out after 600 seconds.

### Testing the connection speed

For the following data connectors, if Structural is able to connect to the database, then it also tests and reports on the connection speed.

* MySQL
* Oracle
* PostgreSQL
* SQL Server

## File connector source and destination data <a href="#workspace-config-connection-file-connector" id="workspace-config-connection-file-connector"></a>

A [file connector](https://docs.tonic.ai/app/setting-up-your-database/file-connector) workspace uses files as its source data and produces transformed versions of those files as its output.

For file connector workspaces, the **File Location** section indicates where the source files are obtained from - either a local file system or a cloud storage solution (Amazon S3 or Google Cloud Storage).

When the files come from cloud storage, the **Output Location** section indicates where to write the transformed files. You must also provide the cloud storage connection credentials.

For more information, go to [file-connector-workspace-config](https://docs.tonic.ai/app/setting-up-your-database/file-connector/file-connector-workspace-config "mention").
