# Amazon Athena

## Set up an Amazon Athena data connection

When inside a workbook, click **View** > **Databases**, then click the **+** icon and follow the on-screen instructions. For more information on how to configure Amazon Athena and how to generate access keys, click [here](https://docs.aws.amazon.com/athena/latest/ug/what-is.html). Make sure the IAM user associated with the credentials has write access to the specified output bucket/folder. The output folder is used to write results of your query to and is ideally separated from the main data in the bucket.

Note: the output bucket should be an s3 url, meaning it should start with `s3://`

<figure><img src="https://4179539225-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZqboFGZzD87nn7oPsm%2Fuploads%2FeCv3xAdYvBhJkEOQ8e0e%2FScreenshot%202023-10-12%20at%2013.53.56.png?alt=media&#x26;token=266ccdc7-0845-4e65-a9b4-c37c8323f7e3" alt=""><figcaption></figcaption></figure>

For detailed instructions, see [connect-your-data-to-workspace](https://datalab-docs.datacamp.com/connect-to-data/connect-your-data-to-workspace "mention").

## Query the database

You can now query Amazon Athena with a [sql-cell](https://datalab-docs.datacamp.com/work/sql-cell "mention"). Select it in the **Select source** dropdown in the top left corner of a SQL cell, or select the sample Amazon Athena connection.

<figure><img src="https://4179539225-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZqboFGZzD87nn7oPsm%2Fuploads%2Fx8NW4emmSdkhJwNFfAnw%2Fimage.png?alt=media&#x26;token=3e41a99d-ca5a-4afd-8503-100e0d3b6e7f" alt=""><figcaption><p>Example of a SQL cell using the <code>MyAthena</code> connection. The query result is available as <code>df1</code>.</p></figcaption></figure>
