Daniel Furr
Daniel Furr

Reputation: 11

How to connect to Amazon Athena using a session token in R?

I am trying to use R to connect to Amazon Athena using temporary credentials that include a session token. In the past, the session token was not required, and so I was able to connect using R code like the following:

library(RJDBC)

fil <- "~/Data/AthenaJDBC41-1.1.0.jar"
drv <- JDBC(driverClass = "com.amazonaws.athena.jdbc.AthenaDriver", fil, identifier.quote="'")

con <- dbConnect(drv, "jdbc:awsathena://athena.us-east-1.amazonaws.com:443/",
                 s3_staging_dir = "...", user = "...", password = "...")

Now I am required to use a session token, but I have not been able to figure out how to include the token as an option to dbConnect. Is this possible? How can it be done?

Upvotes: 0

Views: 1124

Answers (1)

Daniel Furr
Daniel Furr

Reputation: 11

A colleague provided the answer to me. An example is:

dbConnect(odbc(), 
          .connection_string = "Driver={Simba Athena ODBC Driver};",
          driver = "/Library/simba/athenaodbc/lib/libathenaodbc_sbu.dylib", 
          Schema = "...",
          AwsRegion = "...",
          AuthenticationType = "IAM Credentials",
          UID = "...",
          PWD = "...",
          sessiontoken = "...",
          S3OutputLocation = "...")

Upvotes: 1

Related Questions