diff --git a/docs/athena/RStudio/README.md b/docs/athena/RStudio/README.md index a0b54066..ab56af29 100644 --- a/docs/athena/RStudio/README.md +++ b/docs/athena/RStudio/README.md @@ -17,6 +17,7 @@ This uses [R-DBI library](https://dbi.r-dbi.org) through ODBC connection to Athe ``` aws sso login --profile prodops +yawsso -p prodops ``` ### Step 3 @@ -46,24 +47,90 @@ con <- DBI::dbConnect( select count(1) from "AwsDataCatalog"."multiqc"."dragen_umccrise"; ``` -- You can also use more programmatic way with R through `glue` or `dbplyr` then `ggplot2`. See [3] for more details. +- You can also use more programmatic way with R through `glue` or `dbplyr` then `ggplot2`. +- See [3] for more details. + + +## MacOS + +> If you are on macOS, you may need the following additional steps. + +- Update Simba ODBC config file to match as follows. + +``` +sudo vi /Library/simba/athenaodbc/lib/simba.athenaodbc.ini +``` + +``` +[Driver] +## - Note that this default DriverManagerEncoding of UTF-32 is for iODBC. +ErrorMessagesPath=/Library/simba/athenaodbc/ErrorMessages +LogLevel=0 +LogPath= +SwapFilePath=/tmp +Driver=/Library/simba/athenaodbc/lib/libathenaodbc_sb64.dylib +ODBCInstLib=/usr/local/lib/libodbcinst.dylib +``` + +- Install [unixODBC](http://www.unixodbc.org) + +``` +brew install unixodbc +``` + +- List unixODBC config file locations + +``` +odbcinst -j + + unixODBC 2.3.11 + DRIVERS............: /usr/local/etc/odbcinst.ini + SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini + FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources + USER DATA SOURCES..: /Users//.odbc.ini + SQLULEN Size.......: 8 + SQLLEN Size........: 8 + SQLSETPOSIROW Size.: 8 +``` + +- Update unixODBC config file to match as follows. + +``` +vi /usr/local/etc/odbcinst.ini +``` + +``` +[Simba Athena ODBC Driver] +Driver=/Library/simba/athenaodbc/lib/libathenaodbc_sb64.dylib +``` + +- See [4] [5] for additional resources. ## Starter Demo +### Scripts + - [athena.R](athena.R) - [athena.sql](athena.sql) - [athena_federated_query.sql](athena_federated_query.sql) +### Windows + ![rstudio_dbi_odbc_athena_1.png](rstudio_dbi_odbc_athena_1.png) ![rstudio_dbi_odbc_athena_2.png](rstudio_dbi_odbc_athena_2.png) ![rstudio_dbi_odbc_athena_federated_query.png](rstudio_dbi_odbc_athena_federated_query.png) +### MacOS + +![rstudio_dbi_odbc_athena_macOS.png](rstudio_dbi_odbc_athena_macOS.png) ## REF * [1] https://docs.aws.amazon.com/athena/latest/ug/connect-with-odbc.html * [2] https://solutions.rstudio.com/db/databases/athena/ * [3] https://www.rstudio.com/blog/working-with-databases-and-sql-in-rstudio/ +* [4] https://exploratory.io/note/exploratory/How-to-use-Amazon-Athena-ODBC-Driver-on-Mac-UtO9zcN7 +* [5] https://github.com/r-dbi/odbc diff --git a/docs/athena/RStudio/rstudio_dbi_odbc_athena_macOS.png b/docs/athena/RStudio/rstudio_dbi_odbc_athena_macOS.png new file mode 100644 index 00000000..b2c50399 Binary files /dev/null and b/docs/athena/RStudio/rstudio_dbi_odbc_athena_macOS.png differ