View source: R/athena_connection.R
connect_athena | R Documentation |
Creates a connection object which permits the user to interact with the Athena databases that are hosted on the MoJ's Analytical Platform. It uses the noctua package, with the MoJ's authentication. This returns an object with class MoJAthenaConnection, which inherits methods from noctua's AthenaConnection class, which in turn are DBI methods. In general the expected usage is to run the function with no arguments to get a standard database connection, which should work for most basic data access purposes.
connect_athena(
aws_region = NULL,
staging_dir = NULL,
rstudio_conn_tab = FALSE,
session_duration = 3600L,
role_session_name = NULL,
schema_name = "default",
...
)
aws_region |
This is the region where the database is held. If unset or NULL then will default to the AP's region. |
staging_dir |
This the s3 location where outputs of queries can be held. If unset or NULL then will default to a session specific temporary dir. |
rstudio_conn_tab |
Set this to true to show this connection in you RStudio connections frame (warning: this takes a long time to load because of the number of databases in the AP's Athena) |
session_duration |
The number of seconds which the session should last before needing new authentication. Minimum of 900. |
role_session_name |
This is a parameter for authentication, and should be left to NULL in normal operation. |
schema_name |
This is the default database that tables not specifying a database will be looked in. If this is set to the string |
... |
Other agruments passed to |
See also noctua's documentation for connecting to a database noctua::dbConnect,AthenaDriver-method
con <- connect_athena() # creates a connection with sensible defaults
data <- dbGetQuery(con, "SELECT * FROM database.table") # queries and puts data in R environment
dbDisconnect(con) # disconnects the connection
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.