# Data Sources Blocks

## Overview

The data sources blocks allow you to perform a variety of CRUD (**C**reate, **R**ead, **U**pdate, **D**elete) operations on records you have stored in Airtable, Google Sheets, or a local table.

![](https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2FLv3rkpscNIBaD5P5suet%2FBlocks%20%3E%20App%20Features%20%3E%20Data%20Sources.png?alt=media\&token=4ae3c3d7-b8f3-4d03-b919-e779a4bad92c)

## Create Data

### Video Tutorial

#### How to Create Data in a Thunkable Data Source

In this tutorial, we’ll demonstrate how to create data in a connected data source such as Google Sheets, Airtable, or a local table.

{% embed url="<https://youtu.be/mxyjQRv4aDg>" %}

**Template app:**&#x20;

1. Click: <https://x.thunkable.com/projectPage/64668b45dace620c9c533936>
2. Click **Copy Project** in the upper right.

**Copy of spreadsheet:** [Google Sheet - Thunkable Employee Directory](https://docs.google.com/spreadsheets/d/1hMdJ1O-uekCi1_aT4OpWInk_bS_pvU3zouqYYXE2sn4/copy)

### Create Row In Block Overview

The **create row in** block allows you to append new rows to the end of your data tables.&#x20;

![](https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-M5aGJ1wOENtwwwS3swV%2F-M5aPpI5KxOgLLhjwyBr%2Fcreate_row.png?alt=media\&token=9f08bf0a-126a-421e-8826-ea5839c5fed5)

The inputs are dynamic, so if you change the name of Column 1 or Column 2 in the data source, these changes will also be reflected in the block. You can only connect text and numbers to the **create row in** block.

There is a second **create row in** block which allows you to add a row in your data source using an object. The field is the column name and the cell info is the value you would like to set.

<div align="left"><figure><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2FJZschHkepbGgDYRJSm9t%2Fcreate%20row%20object.png?alt=media&#x26;token=75e0a9f5-4b4c-440b-998a-1761c360f239" alt="" width="563"><figcaption></figcaption></figure></div>

## Read Data

### Video Tutorial

#### **How to Read Data in a Thunkable Data Source**

In this tutorial, we’ll demonstrate how to read data in a connected data source such as Google Sheets, Airtable, or a local table.

{% embed url="<https://youtu.be/kXex673U2Aw>" %}

**Template app:**&#x20;

1. Click: <https://x.thunkable.com/projectPage/64668bc2fa089d617bb706c3>
2. Click **Copy Project** in the upper right.

**Copy of spreadsheet:** [Google Sheet - Thunkable Employee Directory](https://docs.google.com/spreadsheets/d/1hMdJ1O-uekCi1_aT4OpWInk_bS_pvU3zouqYYXE2sn4/copy)

### Get Value From Block Overview

The **get value from** block allows you to read a value from a specific cell in your data table. You can specify the column name and the view in the block itself and pass the unique row id as an input.

<div align="left"><figure><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2FpzmhYPSi9Q2bRQo467RO%2Fget%20value%20from.png?alt=media&#x26;token=00c93d81-a98c-406a-8d76-97fd88c89fe1" alt="" width="445"><figcaption></figcaption></figure></div>

{% hint style="warning" %}
The valid id types are index and unique id. The index refers to the row by its integer position (1 for the first row, 2 for the second row, etc.) and must be greater than zero.
{% endhint %}

### Get Row Object From Block Overview

The **get row object from** block returns the row object of the specified row ID. The row object can be used with [Objects Blocks.](https://docs.thunkable.com/blocks/blocks/objects)

<div align="left"><figure><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2FL2MjCf3VG2ksq5QKXcsf%2Fget%20row%20object%20from.png?alt=media&#x26;token=9acfe0f6-b455-43c6-bd53-8d74d2398e01" alt="" width="493"><figcaption></figcaption></figure></div>

### Get First Row Object From Block Overview

The **get first row object from** block returns the row object of the first row that meets the specified condition. You can specify the column name and condition in the block itself and pass the value as an input. The row object can be used with [Objects Blocks.](https://docs.thunkable.com/blocks/blocks/objects)

<div align="left"><figure><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2Fs48g3shCO6KNIYsHF2fC%2Fget%20first%20row%20object%20from.png?alt=media&#x26;token=a0a5e6be-d1cb-49e3-9fea-e3508664b3ef" alt="" width="455"><figcaption></figcaption></figure></div>

### List of Value In Block Overview

The **list of values in** block allows you to read an entire column of data from a table and returns it as a list you can then manipulate with the [List Blocks](https://docs.thunkable.com/blocks/blocks/lists).

<figure><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2FUZY1JMFyK7qmH3Halv5G%2Flist%20of%20values%20in.png?alt=media&#x26;token=e6aee0e4-9a23-4781-bb7e-066dd3a0701c" alt=""><figcaption></figcaption></figure>

### Number of Rows In Block Overview

The **number of rows in** block returns an integer corresponding to how many rows are in a given data source.

<figure><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2FvfuQzbPzWot29D37rp6p%2Fnumber%20of%20rows%20in.png?alt=media&#x26;token=6fbd1564-ccd2-4770-8c62-ea0fd00ff5c6" alt=""><figcaption></figcaption></figure>

### Columns In Block Overview

The **columns in** block returns the column names of a data source

<div align="left"><figure><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2Fkv9UOqBmWIJrTQpxDBvQ%2Fcolumns%20in.png?alt=media&#x26;token=6571c798-153c-4874-a964-4f1f981bc252" alt=""><figcaption></figcaption></figure></div>

## Update Data

### Video Tutorial

#### How to Update Data in a Thunkable Data Source

In this tutorial, we’ll demonstrate how to update data in a connected data source such as Google Sheets, Airtable, or a local table.

{% embed url="<https://youtu.be/ZvaW8YON2oU>" %}

**Template app:**&#x20;

1. Click: <https://x.thunkable.com/projectPage/64668b079fd0bb4094b4f86f>
2. Click **Copy Project** in the upper right.

**Copy of spreadsheet:** [Google Sheet - Thunkable Employee Directory](https://docs.google.com/spreadsheets/d/1hMdJ1O-uekCi1_aT4OpWInk_bS_pvU3zouqYYXE2sn4/copy)

### Update Value In Block Overview

The **update value in** block allows you to modify or update an existing cell in your data source. The column name and view are specified in the block itself. The **row id** and new **value** are passed as inputs.&#x20;

<div align="left"><figure><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2FaFozpzbJrZ86KBkd2vwL%2Fupdate%20value%20.png?alt=media&#x26;token=dd4f273b-7577-443e-87ee-7a5376046d6d" alt="" width="500"><figcaption></figcaption></figure></div>

There is a second **update row in** block which allows you to update a row in your data source using an object. The field is the column name and the cell info is the value you would like to set.

<div align="left"><figure><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2FCEOWopmM54C763ixZBD7%2Fupdate%20row.png?alt=media&#x26;token=3b4d44f5-53fe-4a9c-8fba-97aa98d402ed" alt="" width="443"><figcaption></figcaption></figure></div>

## Delete Data

### Video Tutorial

#### How to Delete Data in a Thunkable Data Source

In this tutorial, we’ll demonstrate how to delete data in a connected data source such as Google Sheets, Airtable, or a local table.

{% embed url="<https://youtu.be/Ab66agEf3ok>" %}

**Template app:**&#x20;

1. Click: <https://x.thunkable.com/projectPage/64668ac3fa089d0fb2b6ec97>
2. Click **Copy Project** in the upper right.

**Copy of spreadsheet:** [Google Sheet - Thunkable Employee Directory](https://docs.google.com/spreadsheets/d/1hMdJ1O-uekCi1_aT4OpWInk_bS_pvU3zouqYYXE2sn4/copy)

### Delete Row In Block Overview

The **delete row in** block allows you to delete a row of data from your data source. The row id is passed as an input. If there is an error, the error message is passed as an output.&#x20;

<div align="left"><figure><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2FT4pKanc86VVqwQXeGOta%2Fdelete%20row.png?alt=media&#x26;token=174f108f-b2b1-4913-baf1-945230eb575c" alt="" width="437"><figcaption></figcaption></figure></div>

### Delete All Rows In Block Overview

The **delete all rows in** block allows you to delete all rows in your data source. If there is an error, the error message is passed as an output.

<div align="left"><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MHVZY9uFn5voyXFM3Ud%2F-MHVaRe5XI7cTbrCazZA%2Fdatasourcedeleteallrows.png?alt=media&#x26;token=4b8b8d86-0188-4be1-abae-d4cf92669ded" alt="" width="375"></div>

{% hint style="info" %}
The **delete all rows in** block is not available when Airtable is the connected data source.
{% endhint %}

## Filter

### Update Filter For Block Overview

The **update filter for** block allows you to edit the value for each condition within a specific view of your data source.

<div align="left"><figure><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2FnPtb3mXHZmohTY8JTByJ%2Fupdate%20filter%20for.png?alt=media&#x26;token=e1366163-4a47-46cd-900e-5c1bb5734ff1" alt=""><figcaption></figcaption></figure></div>
