[Yandex Cloud documentation](../../index.md) > [Yandex Query](../index.md) > Data sources and sinks > Working with Yandex Object Storage > Writing data

# Writing data to Yandex Object Storage

In Yandex Query, you can use [connections](#connection-write) or [bindings](#bindings-write) to write data to Yandex Object Storage buckets.

Query example for writing `JSON` data via a binding:

```sql
INSERT INTO `my_binding`
SELECT
    "value" AS value, "name" AS name
FROM
    $data;
```

For a list of supported data formats and compression algorithms, see [Supported write formats](#write-formats).

## Writing data via connections {#connection-write}

Connections are a convenient way to write data when prototyping or initially configuring data writing. To write data to a bucket, create a [connection](object-storage.md#create_connection) to Object Storage and then use the following SQL statement:

```sql
INSERT INTO <connection>.<path>
    WITH
    (
        format='<data_format>',
        compression='<compression_format>'
    )
SELECT
    <expression>
FROM
    <query>
```

Where:

* `<connection>`: Object Storage connection name.
* `<path>`: Target path within the bucket.
* `<query>`: Query source data query.

### Example {#connection-write-example}

Query example for writing data to Object Storage via connections:

```sql
INSERT INTO `connection`.`test/`
    WITH
    (
        format='csv_with_names'
    )
SELECT
    "value" AS value, "name" AS name
```

Where:

* `connection`: Object Storage connection name.
* `test/`: Target path within the bucket.

## Writing data via bindings {#bindings-write}

If you need to write data regularly, you can use bindings to avoid specifying all data operation details in each query. To write data to a bucket, create a [binding](object-storage-binding.md) in Object Storage and then use the following SQL statement:

```sql
INSERT INTO `<binding>`
SELECT
    <expression>
FROM
    <query>
```

Where:

* `<binding>`: Object Storage data binding name.
* `<query>`: Query source data query.

### Example {#bindings-write-example}

Query example for writing data to Object Storage via a binding:

```sql
INSERT INTO `test`
SELECT
    "value" AS value, "name" AS name
```

Where:

* `test`: Object Storage data binding name.

## Supported write formats {#write-formats}

The service currently supports the following formats for writing data:

|Data format|Name in Query|
|--|--|
|[CSV](https://en.wikipedia.org/wiki/Comma-separated_values)|[csv_with_names](formats.md#csv_with_names)|
|[Parquet](https://en.wikipedia.org/wiki/Apache_Parquet)|[parquet](formats.md#parquet)|

Query supports the following compression algorithms for writing data:

|Compression format|Name in Query|
|--|--|
|[Gzip](https://en.wikipedia.org/wiki/Gzip)|gzip|
|[Zstd](https://en.wikipedia.org/wiki/Zstandard)|zstd|
|[LZ4](https://en.wikipedia.org/wiki/LZ4_(compression_algorithm))|lz4|
|[Brotli](https://en.wikipedia.org/wiki/Brotli)|brotli|
|[Bzip2](https://en.wikipedia.org/wiki/Bzip2)|bzip2|
|[Xz](https://en.wikipedia.org/wiki/Lempel–Ziv–Markov_chain_algorithm#xz_and_7z_formats)|xz|

While the `parquet` format supports built-in compression algorithms, Query also enables you to write `parquet` data using these:

|Compression format|Name in Query|
|--|--|
|[Snappy](https://en.wikipedia.org/wiki/Snappy_(compression))| None (used by default) |