# Database Connector

## 🔃 What is the Database Connector ?

Using this connector we can connect our panel to any table with a primary key or any view available in any databases like SQL Server, Oracle, Postgres, MySQL or MariaDB.

{% hint style="info" %}
Using the database connector you could for example connect an existing customer table from your database to ngSurvey and then re-use the information you have about these customers within your surveys.
{% endhint %}

## ➕ Adding a Database connector

To add an ngSurvey connector you may click on the **New panel** button on the [panel management](https://docs.ngsurvey.com/panels) screen and select either the **Database Table Connector** or the **Database View Connector**.

![](https://1025048312-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8fLhS0bmfBRyq0HdUm%2F-MC3MOhW6caE3tR3ItaK%2F-MC3MrjV7E4As9poIQ7I%2Fcaptured%20\(38\).gif?alt=media\&token=fe2efc02-075a-42b1-9d07-e0813163dcd2)

{% hint style="warning" %}
A primary key is required on the table you wish you to connect to and this primary key column will be automatically mapped to the source uid column of your panel.
{% endhint %}

## 🔅 Database connector properties

* **`Database connection string`** [connection string](https://www.connectionstrings.com/sql-server/) to your   database.
* **`Table to connect to the panel`** table of your database that will be used for your panel. Your table needs to have one primary key.
* **`Table columns to syncronize`** columns of your table that will be used as attributes.
* **`Sync mode`** whether or not the data synchronization of the table will be triggered manually from the [panel information box](https://docs.ngsurvey.com/panels/panel-information) or automatically.
* **`Data sync type`** what changes from the table should be updated after the panel has been created and its data synchronized the first time.
  * **Add** will add new entries from the table to the panel.
  * **Update** will update any changes from the table to the panel.
  * **Delete** will delete any deleted row from the table to the panel.&#x20;
* **`Connector source update mode`** how the data updates within ngSurvey will propagate to the connected table.
  * **After approval** requires you to approve any changes done before these are getting pushed back to the table.
  * **Live link** updates immediately the table with any updates done on the ngSurvey side.
  * **Not allowed** no changes or updates will be pushed back to the SQL table.
* **`Source synchronization interval`**&#x6D;inutes after which the table will be synchronized again if the sync mode is set to Automatic.

## &#x20;[✅](https://emojipedia.org/check-mark-button/) **Supported Panel Connector Modes**

* **Read**   Allows to synchronize structure and data from a table or  View.
* **Update** Allows to [update existing data](https://docs.ngsurvey.com/form-management/form-designer/questions/panel-linking/panel-updating) in the connected table.&#x20;

## ⚠️ **Known Limitations / Issues**

The database Connector has some limitations listed below.

* One primary key,  only table with a single primary key are supported at this time.
* Its not possible to add new columns for synchronizing once the panel has been created.

## 🔢 Supported SQL Server Types

Following SQL Server column types are currently supported for synchronization.

* bigint
* int
* smallint
* tinyint
* bit
* decimal
* numeric
* money
* smallmoney
* float
* real
* datetime
* smalldatetime
* char
* varchar
* text
* nchar
* nvarchar
* ntext
