Skip to main content

A simple athena wrapper leveraging boto3 to execute queries and return results while only requiring a database and a query string.

Project description

pythena

This is a simple python module that will allow you to query athena the same way the AWS Athena console would. It only requires a database name and query string.

Install

pip install pythena

Usage

import pythena

# Returns results as a pandas dataframe
df = pythena.execute(database="mydatabase", query="select * from mytable")

print(df.sample(n=2)) # Prints 2 rows from your dataframe

Specify an s3 url to save results to a bucket.

import pythena

# Returns results as a pandas dataframe
df = pythena.execute(database="mydatabase", 
                    query="select * from mytable", 
                    s3_output_url="s3://mybucket/mydir")

print(df.sample(n=2)) # Prints 2 rows from your dataframe

Note

By default, when executing athena queries, via boto3 or the AWS athena console, the results are saved in an s3 bucket. This module by default, assuming a successful execution, will delete the s3 result file to keep s3 clean. If an s3_output_url is provided, it the result file will not be deleted.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pythena-0.1.0.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

pythena-0.1.0-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page