# SELECT INTO S3 - file format

**URL:** <https://www.singlestore.com/forum/t/select-into-s3-file-format/2001>\
**Category:** Off-Topic\
**Created:** [May 21, 2020, 7:48am UTC](https://www.singlestore.com/forum/t/select-into-s3-file-format/2001 "2020-05-21T07:48:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ido](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/i/e274bd/32.png) [@ido](https://www.singlestore.com/forum/u/ido)\
**Post date:** [May 21, 2020, 7:48am UTC](https://www.singlestore.com/forum/t/select-into-s3-file-format/2001/1 "2020-05-21T07:48:23Z")

</div>

Hello,

I managed to successfully load data from mem to S3 bucket.  
But the format is something I cannot use.

Can i make it JSON or CSV?

```auto
SELECT *
FROM table
WHERE time > '2020-05-20 00:00:00' 
INTO S3 'bucket/file'
CONFIG '{}'
CREDENTIALS '{"aws_access_key_id":" ***","aws_secret_access_key":"***"}'

```

Regards,

---

<div class="post-metadata">

**Author:** ![nikita](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/n/a8b319/32.png) [@nikita](https://www.singlestore.com/forum/u/nikita)\
**Post date:** [May 21, 2020, 3:58pm UTC](https://www.singlestore.com/forum/t/select-into-s3-file-format/2001/2 "2020-05-21T15:58:53Z")

</div>

With 7.1 you would be able to run select to\_json(\*) from table

---

<div class="post-metadata">

**Author:** ![nikita](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/n/a8b319/32.png) [@nikita](https://www.singlestore.com/forum/u/nikita)\
**Post date:** [May 21, 2020, 3:59pm UTC](https://www.singlestore.com/forum/t/select-into-s3-file-format/2001/3 "2020-05-21T15:59:25Z")

</div>

> **[SingleStoreDB Cloud · SingleStore Documentation](https://docs.singlestore.com/v7.1/reference/sql-reference/json-functions/to_json/)**
>
> SingleStore is a modern relational database for cloud and on-premises that delivers immediate insights for modern applications and analytical systems. Book a demo or trial today!

---

<div class="post-metadata">

**Author:** ![rob](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/r/838e76/32.png) [@rob](https://www.singlestore.com/forum/u/rob)\
**Post date:** [May 21, 2020, 9:35pm UTC](https://www.singlestore.com/forum/t/select-into-s3-file-format/2001/4 "2020-05-21T21:35:52Z")

</div>

You can configure the output format of `INTO OUTFILE` via the same options as `LOAD DATA`. See here for reference: [SELECT · SingleStore Documentation](https://docs.memsql.com/v7.0/reference/sql-reference/data-manipulation-language-dml/select/#select--into-outfile)

---

<div class="post-metadata">

**Author:** ![hanson](https://www.singlestore.com/forum/user_avatar/www.singlestore.com/hanson/32/196_2.png) [@hanson](https://www.singlestore.com/forum/u/hanson)\
**Post date:** [May 27, 2020, 5:52pm UTC](https://www.singlestore.com/forum/t/select-into-s3-file-format/2001/5 "2020-05-27T17:52:02Z")

</div>

You can export to CSV format using SELECT INTO OUTFILE/S3, using the instructions that @rob linked to above. The CONFIG and CREDENTIALS go first, then the formatting instructions. E.g.

```
SELECT * FROM t INTO S3 'tmp/a'
        CONFIG '{"region":"us-east-1"}'
        CREDENTIALS '{"aws_access_key_id":"your_access_key_id","aws_secret_access_key":"your_secret_access_key"}'
        FIELDS TERMINATED BY ','
        LINES TERMINATED BY '\n'

```

The TO\_JSON function implementation was not quite ready for 7.1, so has been removed from the general availability (GA) release, coming shortly. We are considering options for when to deliver it, and will report back later when we have a firm delivery date.

---

<div class="post-metadata">

**Author:** ![swateek](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@swateek](https://www.singlestore.com/forum/u/swateek)\
**Post date:** [November 30, 2023, 6:06am UTC](https://www.singlestore.com/forum/t/select-into-s3-file-format/2001/6 "2023-11-30T06:06:56Z")

</div>

How do we restore data from an OUTFILE on S3?

---

<div class="post-metadata">

**Author:** ![hanson](https://www.singlestore.com/forum/user_avatar/www.singlestore.com/hanson/32/196_2.png) [@hanson](https://www.singlestore.com/forum/u/hanson)\
**Post date:** [November 30, 2023, 5:01pm UTC](https://www.singlestore.com/forum/t/select-into-s3-file-format/2001/7 "2023-11-30T17:01:35Z")

</div>

With LOAD DATA or PIPELINES, typically. You’d have to write your LOAD DATA or CREATE PIPELINE command in a way that understood the file format.
