> For the complete documentation index, see [llms.txt](https://docs.cloud.hoverfly.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cloud.hoverfly.io/create-simulations/using-data-sources-in-simulations/updating-data-in-data-sources.md).

# Updating data in data sources

### Updating data in a CSV Data Source

You can update data within a CSV data source on the fly within your simulation just as if your API were updating a real data source. The data is modified for the duration that the service is running. When the service is restarted, the data will revert to what was in the original uploaded CSV.

For illustration we will use this data source called "pets":

| id   | category | name   | status    |
| ---- | -------- | ------ | --------- |
| 1000 | birds    | Archie | available |
| 1001 | dogs     | Zipper | available |
| 1002 | dogs     | Teddy  | sold      |

### Update data with {{csvSqlCommand}}

A simplified SQL like syntax can be used to update the data in a csv data source. (This syntax can also be used to [SELECT ](/create-simulations/using-data-sources-in-simulations/querying-data-sources.md)and [DELETE ](/create-simulations/using-data-sources-in-simulations/deleting-data-from-data-sources.md)from the data source. You cannot insert using this syntax however there is a mechanism which can be read about [here](/create-simulations/using-data-sources-in-simulations/inserting-data-into-a-data-source.md).)

You can read more about using this SQL like syntax [here](/create-simulations/using-data-sources-in-simulations/guidance-on-using-the-sql-like-syntax.md).

Syntax:

```handlebars
{{ csvSqlCommand 'sql-update-statement' }}
```

Template Example: Set the status of pets with a name of 'Archie' to 'sold'

```handlebars
{{ csvSqlCommand "UPDATE pets SET status = 'sold' WHERE name = 'Archie' }}
```

Result:

There is no output from an UPDATE statement but the data in memory for all subsequent calls to the API simulation will be modified as follows:

| id   | category | name   | status    |
| ---- | -------- | ------ | --------- |
| 1000 | birds    | Archie | sold      |
| 1001 | dogs     | Zipper | available |
| 1002 | dogs     | Teddy  | sold      |

###
