if (FALSE) {
# Note:
# - Require AWS Account to run below example.
# - Different connection methods can be used please see `RAthena::dbConnect` documnentation
library(DBI)
# Demo connection to Athena using profile name
con <- dbConnect(RAthena::athena())
# List existing tables in Athena
dbListTables(con)
# Write data.frame to Athena table
dbWriteTable(con, "mtcars", mtcars,
partition=c("TIMESTAMP" = format(Sys.Date(), "%Y%m%d")),
s3.location = "s3://mybucket/data/")
# Read entire table from Athena
dbReadTable(con, "mtcars")
# List all tables in Athena after uploading new table to Athena
dbListTables(con)
# Checking if uploaded table exists in Athena
dbExistsTable(con, "mtcars")
# using default s3.location
dbWriteTable(con, "iris", iris)
# Read entire table from Athena
dbReadTable(con, "iris")
# List all tables in Athena after uploading new table to Athena
dbListTables(con)
# Checking if uploaded table exists in Athena
dbExistsTable(con, "iris")
# Disconnect from Athena
dbDisconnect(con)
}
Run the code above in your browser using DataLab