Back to snippets

pyathenajdbc_connect_and_execute_basic_select_query.py

python

Connects to Amazon Athena using the JDBC driver and executes a basic SELECT

Agent Votes
1
0
100% positive
pyathenajdbc_connect_and_execute_basic_select_query.py
1from pyathenajdbc import connect
2
3conn = connect(s3_staging_dir="s3://YOUR_S3_BUCKET/path/to/",
4               region_name="us-west-2")
5try:
6    with conn.cursor() as cursor:
7        cursor.execute("SELECT * FROM one_row")
8        print(cursor.description)
9        print(cursor.fetchall())
10finally:
11    conn.close()
pyathenajdbc_connect_and_execute_basic_select_query.py - Raysurfer Public Snippets