View a markdown version of this page

Linux - Amazon Athena

Linux

Choose a workgroup and authentication method, and grant the connection credentials athena:GetWorkGroup. For a DuckDB connection, use a DuckDB workgroup and leave EngineVersion unset for the initial connection.

Install

Use the platform installer for your client computer and configure the installed driver with your ODBC driver manager.

sudo rpm -Uvh AmazonAthenaODBC-4.0.0.0-x86_64.rpm rpm -qa | grep amazon-athena-odbc-driver

Configure the driver and DSN

The installed examples are in /opt/amazon/athena-odbc/share/athena-odbc. Copy odbc.ini.example and odbcinst.ini.example into your configuration directory and remove the .example suffix.

sudo mkdir -p /opt/amazon/athena-odbc/etc/athena-odbc sudo cp /opt/amazon/athena-odbc/share/athena-odbc/odbc.ini.example /opt/amazon/athena-odbc/etc/athena-odbc/odbc.ini sudo cp /opt/amazon/athena-odbc/share/athena-odbc/odbcinst.ini.example /opt/amazon/athena-odbc/etc/athena-odbc/odbcinst.ini

Configure odbcinst.ini with the registered driver name and installed library path.

[ODBC Drivers] Amazon Athena ODBC (x64)=Installed [Amazon Athena ODBC (x64)] Driver=/opt/amazon/athena-odbc/lib/libathenaodbc.so Setup=/opt/amazon/athena-odbc/lib/libathenaodbc.so

Configure odbc.ini with your DSN. Replace the Region, workgroup, and database in the following example; this connection uses the default credentials provider chain.

[ODBC Data Sources] athena_odbc_test=Amazon Athena ODBC (x64) [athena_odbc_test] Driver=/opt/amazon/athena-odbc/lib/libathenaodbc.so AwsRegion=us-west-2 Workgroup=my-duckdb-workgroup Catalog=AwsDataCatalog Schema=my_database AuthenticationType=Default Credentials ResultFetcher=auto

These configuration-path settings apply to unixODBC. ODBCSYSINI selects the directory containing the system odbcinst.ini and odbc.ini files.

export ODBCSYSINI=/opt/amazon/athena-odbc/etc/athena-odbc

Test the connection

Use the unixODBC isql command to attempt a connection to athena_odbc_test. At its SQL prompt, submit a query such as SELECT 1.

isql "athena_odbc_test"