# NOT RUN {
# Note:
# - Require AWS Account to run below example.
# - Different connection methods can be used please see `RAthena::dbConnect` documnentation
library(DBI)
library(dplyr)
# Demo connection to Athena using profile name
con <- dbConnect(RAthena::athena())
# List existing tables in Athena
dbListTables(con)
# Write data.frame to Athena table
copy_to(con, mtcars,
s3_location = "s3://mybucket/data/")
# Checking if uploaded table exists in Athena
dbExistsTable(con, "mtcars")
# Write Athena table from tbl_sql
athena_mtcars <- tbl(con, "mtcars")
mtcars_filter <- athena_mtcars %>% filter(gear >=4)
copy_to(con, mtcars_filter)
# Checking if uploaded table exists in Athena
dbExistsTable(con, "mtcars_filter")
# Disconnect from Athena
dbDisconnect(con)
# }
Run the code above in your browser using DataLab