# Database Connections

{% hint style="success" %}
**Who can use this feature?**

The **Database Connections** can be used by those with the **Builder** subscription plan.

For more details, see our [**pricing comparison matrix**](https://squirrel365.io/pricing/).
{% endhint %}

The **Database** Connections can be used to connect the Squirrel project to an external InfoBurst database.

There are two different **Database** connections:

* **Database Query** - queries the referenced database and returns the selected query.
* **Database Writeback** - writes back to the selected query and updates the information based on an insertion

## Common Database Connector Properties – Credentials

An Infoburst URL and login credentials are required to use the **Database** connectors. These can be obtained from the Infoburst webpage, as well as the URL port.

### Database Login Credentials

The '**Infoburst URL**' is used to access followed by a port to identify the specific environment.

After entering the URL, all that is needed is a '**Username**' and '**Password**'.

All three of the credential fields can be bound to cells in the spreadsheet.

<figure><img src="https://911720298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkLBGzn2hXrIMe50klQCv%2Fuploads%2FmaB6gOCeUQyk5JQ5sfMu%2FDB_login.png?alt=media&#x26;token=d821b66b-d124-46ed-bb58-240f22335788" alt=""><figcaption></figcaption></figure>

***

## Mapping the data to the spreadsheet

After connecting to the database, the **DATA MAPPING** properties will populate which is where you can define the cache or cache query to be brought into Squirrel.

***

### Database Query

The **Database Query** DATA MAPPING properties will populate a list of the existing caches within the connected database. After making a selection, the dropdown will outline the number of caches selected.

<figure><img src="https://911720298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkLBGzn2hXrIMe50klQCv%2Fuploads%2FLVv2aw92DeoGcg5k66lJ%2FDBQuery_Mapping.png?alt=media&#x26;token=e718d0d8-e4e2-4159-889d-b253845d38ff" alt=""><figcaption></figcaption></figure>

The selected query will populate below the dropdown to bind its location to the spreadsheet. The **Destination** field will appear to bind the query to an area in the spreadsheet for the data to populate at runtime.&#x20;

**Max Rows** will determine if there is a limit on the number of rows returned from the database.

{% hint style="info" %}
If the database contains parameters defined in the SQL code, a PARAMETER sub-drawer will populate in the DATA MAPPING drawer.
{% endhint %}

<figure><img src="https://911720298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkLBGzn2hXrIMe50klQCv%2Fuploads%2FC5GPmJQPClTE3Jn9o9Ws%2FDBQ_Parameters.png?alt=media&#x26;token=6c6b6dd4-f701-46e7-a0e0-4cca94f1f246" alt=""><figcaption><p>The Parameter inputs that appear will be labelled as the value defined in the Database SQL code.</p></figcaption></figure>

***

### Database Writeback

The **Database Writeback** DATA MAPPING properties will populate a list of the existing cache queries within the connected database. After making a selection, a sub-drawer will populate labeled META DATA.

{% hint style="info" %}
If the database contains parameters defined in the SQL code, a PARAMETER sub-drawer will populate in the DATA MAPPING drawer.
{% endhint %}

<figure><img src="https://911720298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkLBGzn2hXrIMe50klQCv%2Fuploads%2FIwB6FrGjcjnd5bjUSiny%2FDBWB_Statement.png?alt=media&#x26;token=bdc80792-f54b-444c-943d-1e186152983e" alt=""><figcaption></figcaption></figure>

The **FALLBACK STATEMENT** drawer defines a "backup" writeback that will execute only if the initial writeback statement fails. The property panel layout is the same as the original Writeback Statement.

<figure><img src="https://911720298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkLBGzn2hXrIMe50klQCv%2Fuploads%2FCOJ7rz4gAHULGfSBEh14%2FDBWB_Fallback.png?alt=media&#x26;token=ca5b7db3-8fe4-410f-af1a-52f9842a8a59" alt=""><figcaption></figcaption></figure>

The **QUERY ON SUCCESS** drawer is used to run a query if either of the above writeback statements succeeds.

<figure><img src="https://911720298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkLBGzn2hXrIMe50klQCv%2Fuploads%2FHhFNeT1FXMT4Ci0HpRmM%2FDBWB_OnSuccess.png?alt=media&#x26;token=4d82d051-ada2-4723-b4e7-a97f2a857d7a" alt=""><figcaption></figcaption></figure>

***

## Triggering the connection

Like most connections, the properties panel has a **USAGE** drawer that provides control of the connector's triggers.

* **Refresh on Load** - as described, the connection will trigger and the data will be brought through to the spreadsheet on the load of the project. This can be previewed in Debug and Preview modes.
* **Refresh on Interval** - defines an Interval that the connection will refresh. When selected, an input will populate where a period of seconds can be defined for the connection to refresh.
* **Refresh on Cell Changes** - sets the trigger to refresh on the change of another cell. This property utilizes **Conditional Logic**. For more information on **Conditional Logic** and its uses, see [**this article**](https://learn.squirrel365.io/getting-started/dynamic-visibility#conditional-logic).

<figure><img src="https://911720298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkLBGzn2hXrIMe50klQCv%2Fuploads%2FuXPQLwWfqXfCQDgM4hHC%2FCSV_Usage.png?alt=media&#x26;token=a5267798-a930-4077-b4ea-e62b2afd9c98" alt=""><figcaption></figcaption></figure>
