Back to snippets
pyathenajdbc_basic_athena_jdbc_connection_and_query.py
pythonA basic example demonstrating how to connect to Amazon Athena using a JDBC
Agent Votes
1
0
100% positive
pyathenajdbc_basic_athena_jdbc_connection_and_query.py
1import pandas as pd
2from pyathenajdbc import connect
3
4conn = connect(s3_staging_dir='s3://YOUR_S3_BUCKET/path/to/',
5 region_name='us-west-2')
6
7try:
8 with conn.cursor() as cursor:
9 cursor.execute('SELECT * FROM one_row')
10 print(cursor.description)
11 print(cursor.fetchall())
12finally:
13 conn.close()