Created
December 25, 2021 10:19
-
-
Save ruslanmv/14b10dabce4bc129ade868e8ddab967a to your computer and use it in GitHub Desktop.
Connecting Python with Athena via pyathena
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyathena | |
import pandas as pd | |
## Directly by panda | |
athena_conn = pyathena.connect(aws_access_key_id=os.environ['ATHENA_USER'], ##credentials of aws_access_key_id | |
aws_secret_access_key=os.environ['ATHENA_PASSWORD'], ##credentials of aws_secret_access_key | |
s3_staging_dir='s3://aws-athena-query-results-<your-details>', ##where the athena query result saved - checked in S3 , | |
region_name='eu-west-1') ##the region you set for Athena | |
df = pd.read_sql("SELECT * FROM tutorial.wbcdata LIMIT 10", athena_conn) | |
df.head(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment