![]() |
VOOZH | about |
This guide walks you through installing, licensing, and connecting the CData Python Connector to live Amazon Athena data. You will learn to:
Let's begin.
CData provides the easiest way to access and integrate live data from Amazon Athena. Customers use CData connectivity to:
Users frequently integrate Athena with analytics tools like Tableau, Power BI, and Excel for in-depth analytics from their preferred tools.
To learn more about unique Amazon Athena use cases with CData, check out our blog post: https://www.cdata.com/blog/amazon-athena-use-cases.
Python Dependencies Note: Make sure you have Python installed. The CData Python Connector supports Python versions 3.8, 3.9, 3.10, 3.11, and 3.12. If you are using a version outside this range, you may need to create a virtual environment with virtualenv.
pip install cdata_amazonathena_connector-24.0.9111-cp312-cp312-win_amd64.whl
pip install cdata_amazonathena_connector-24.0.####-python3.tar.gz
After your purchase, you should have received your license key via email from the CData Orders Team. The license key is a 25-character code that looks like this: XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
.\license-installer.exe [YOUR LICENSE KEY HERE]
./install-license.sh [YOUR LICENSE KEY HERE]
Can I use my license on multiple machines?
Yes, depending on your subscription tier. Check your order confirmation email or contact your account representative for details.
If you are unsure who your account representative is, contact [email protected].
I lost my license key. How do I retrieve it?
Email [email protected] with your order number, and we will resend your license key.
Can I transfer my license to a different machine?
Yes. You will need to submit a License Transfer Request using our license transfer request page linked below:
https://www.cdata.com/lic/transfer/
After your License Transfer Request is submitted and processed, an additional activation will be added to your Product Key.
You will then be able to activate the full license on the new machine.
Once this process is complete, the license on the previous machine will become invalid.
For additional licensing questions, contact [email protected]. You can view and manage your license through our self-service portal at portal.cdata.com.
After the installation and license activation are complete, you can establish a connection using the CData Python Connector.
The CData Python Connector for Amazon Athena is exposed as a Python module that you can import using the standard import statement and then build your application code around it.
The Connector also includes built-in metadata tools such as sys_tables and sys_tablecolumns, which allow you to perform schema discovery — including available tables, columns, and structural metadata for Amazon Athena data.
The following example establishes a connection to Amazon Athena using your authentication properties and retrieves column names from a specific table.
Replace or modify the connection string values below with your actual credentials, and update your table name in '[TABLE NAME]' as needed.
If your Amazon Athena instance uses MFA or additional security requirements, you may need to include properties such as Passcode or SecurityToken in your connection string. Refer to the Connection String Options section in the Connector Help documentation (also available inside the help directory of the Connector) for a complete list of supported properties.
import cdata.amazonathena as mod
# Establish the connection using your configured properties
conn = mod.connect(
"AWSAccessKey='a123';"
"AWSSecretKey='s123';"
"AWSRegion='IRELAND';"
"Database='sampledb';"
"S3StagingDirectory='s3://bucket/staging/';"
)
# Query column names for the specified table
cur = conn.cursor()
cur.execute("SELECT ColumnName FROM sys_tablecolumns WHERE TableName = '[TABLE NAME]'")
print("Columns in your table:")
for row in cur.fetchall():
print(row[0])
cur.close()
conn.close()
This code connects to Amazon Athena, queries the metadata catalog, and prints all column names for the table you specify. Check out the complete Connector documentation to learn how to modify the SQL query to explore additional schemas, tables, or other supported metadata views.
To authorize Amazon Athena requests, provide the credentials for an administrator account or for an IAM user with custom permissions: Set to the access key Id. Set to the secret access key.
Note: Though you can connect as the AWS account administrator, it is recommended to use IAM user credentials to access AWS services.
To obtain the credentials for an IAM user, follow the steps below:
To obtain the credentials for your AWS root account, follow the steps below:
If you are using the CData Data Provider for Amazon Athena 2018 from an EC2 Instance and have an IAM Role assigned to the instance, you can use the IAM Role to authenticate. To do so, set to true and leave and empty. The CData Data Provider for Amazon Athena 2018 will automatically obtain your IAM Role credentials and authenticate with them.
In many situations it may be preferable to use an IAM role for authentication instead of the direct security credentials of an AWS root user. An AWS role may be used instead by specifying the . This will cause the CData Data Provider for Amazon Athena 2018 to attempt to retrieve credentials for the specified role. If you are connecting to AWS (instead of already being connected such as on an EC2 instance), you must additionally specify the and of an IAM user to assume the role for. Roles may not be used when specifying the and of an AWS root user.
For users and roles that require Multi-factor Authentication, specify the and connection properties. This will cause the CData Data Provider for Amazon Athena 2018 to submit the MFA credentials in a request to retrieve temporary authentication credentials. Note that the duration of the temporary credentials may be controlled via the (default 3600 seconds).
In addition to the and properties, specify , and . Set to the region where your Amazon Athena data is hosted. Set to a folder in S3 where you would like to store the results of queries.
If is not set in the connection, the data provider connects to the default database set in Amazon Athena.
Solution: Verify that your User, Password, and any additional authentication properties required by Amazon Athena are correct. If your data source enforces MFA, SSO, or passcodes, ensure the correct properties are included in the connection string. Refer to the complete Connector documentation for the full list of supported authentication properties, or contact [email protected] for assistance validating authentication settings.
Solution: Confirm that the endpoint URL in your connection string is correct and that outbound HTTPS traffic is allowed from your environment. If you are behind a firewall or proxy, ensure that Python is permitted to reach the service URL. For network configuration details or port requirements, contact [email protected].
Solution: Verify the Database, Schema, and table name in your SQL query. Use metadata views such as sys_tables and sys_tablecolumns to confirm the exact table and column names exposed by Amazon Athena data. If the table name is case-sensitive, ensure you are using the correct casing in your query.
Solution: Ensure the Python Connector is installed in the correct environment. Run pip list to verify that the connector (cdata-amazonathena-connector) is present. If you are using virtual environments, activate the correct environment before executing your script.
Solution: Incorrect property formatting or missing semicolons can prevent the connector from parsing your connection settings. Review your connection string to ensure each property follows the correct Key=Value; format. Refer to the Python Connector documentation for property names supported by Amazon Athena.
For additional connection troubleshooting, contact [email protected] with your full error message (masking sensitive credentials before sending).
With the connector installed and your connection configured, you can now begin working with live Amazon Athena data in Python. Explore the resources below to extend your integration and build complex workflows.
| Python Client | Article Title |
|---|---|
| Python MCP Server | Connect Amazon Athena to AI Assistants With the CData Python MCP Server |
| pandas | Use pandas to Visualize Amazon Athena in Python |
| Dash | Use Dash & Python to Build Web Apps on Amazon Athena |
| SQLAlchemy | Use SQLAlchemy ORMs to Access Amazon Athena in Python |
| petl | Extract, Transform, and Load Amazon Athena in Python |
If you need assistance at any point:
SELECT * FROM sys_tables;
If your question is not covered in this FAQ, contact [email protected].
Download a Community License of the Amazon Athena Connector to get started:
Download NowLearn more:
👁 Amazon Athena IconPython Connector Libraries for Amazon Athena Data Connectivity. Integrate Amazon Athena with popular Python tools like Pandas, SQLAlchemy, Dash & petl.