Nothing
## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
eval = FALSE
)
## -----------------------------------------------------------------------------
# library(DBI)
# library(RTrino)
#
# con <- dbConnect(
# Trino(),
# host = "http://localhost",
# port = 8080,
# catalog = "hive",
# schema = "default"
# )
## -----------------------------------------------------------------------------
# con <- dbConnect(
# Trino(),
# host = "https://trino.example.com",
# port = 443,
# user = Sys.getenv("TRINO_USER"),
# catalog = "hive",
# schema = "analytics",
# auth = trino_auth_basic(
# Sys.getenv("TRINO_USER"),
# Sys.getenv("TRINO_PASSWORD")
# )
# )
## -----------------------------------------------------------------------------
# con <- dbConnect(
# Trino(),
# host = "https://trino.example.com",
# port = 443,
# user = Sys.getenv("TRINO_USER"),
# catalog = "hive",
# schema = "analytics",
# auth = trino_auth_jwt(Sys.getenv("TRINO_TOKEN"))
# )
## -----------------------------------------------------------------------------
# con <- dbConnect(
# Trino(),
# host = "https://trino.example.com",
# port = 443,
# user = Sys.getenv("TRINO_USER"),
# catalog = "hive",
# schema = "analytics",
# auth = trino_auth_oauth2(
# client_id = Sys.getenv("OAUTH_CLIENT_ID"),
# client_secret = Sys.getenv("OAUTH_CLIENT_SECRET"),
# token_url = "https://auth.example.com/oauth/token"
# )
# )
## -----------------------------------------------------------------------------
# con <- dbConnect(
# Trino(),
# host = "https://trino.internal",
# port = 443,
# catalog = "hive",
# schema = "analytics",
# auth = trino_auth_basic(
# Sys.getenv("TRINO_USER"),
# Sys.getenv("TRINO_PASSWORD")
# ),
# ssl_options = trino_ssl(ca_bundle = "/etc/ssl/certs/internal-ca.pem")
# )
## -----------------------------------------------------------------------------
# sales <- dbGetQuery(con, "SELECT * FROM sales LIMIT 100")
## -----------------------------------------------------------------------------
# res <- dbSendQuery(con, "SELECT * FROM sales")
# while (!dbHasCompleted(res)) {
# chunk <- dbFetch(res, n = 10000)
# # summarise, write out, accumulate...
# }
# dbClearResult(res)
## -----------------------------------------------------------------------------
# dbExecute(con, "INSERT INTO memory.default.visits VALUES (1, 'a'), (2, 'b')")
# #> [1] 2
## -----------------------------------------------------------------------------
# sql <- sqlInterpolate(
# con,
# "SELECT * FROM orders WHERE orderdate >= ?since AND orderstatus = ?status",
# since = as.Date("1995-01-01"),
# status = "F"
# )
# sql
# #> <SQL> SELECT * FROM orders
# #> WHERE orderdate >= DATE '1995-01-01' AND orderstatus = 'F'
# dbGetQuery(con, sql)
## -----------------------------------------------------------------------------
# dbWriteTable(con, "sales", data.frame(id = 1:3, label = letters[1:3]))
# dbAppendTable(con, "sales", data.frame(id = 4L, label = "d"))
#
# # Replace the table. The old one is renamed first and restored if the write
# # fails, so a failure does not leave you without it.
# dbWriteTable(con, "sales", data.frame(id = 9L, label = "z"), overwrite = TRUE)
## -----------------------------------------------------------------------------
# dbWithTransaction(con, {
# dbExecute(con, "INSERT INTO sales VALUES (5, 'e')")
# dbExecute(con, "INSERT INTO sales VALUES (6, 'f')")
# })
## -----------------------------------------------------------------------------
# con <- dbConnect(
# Trino(),
# host = "https://trino.example.com",
# port = 443,
# catalog = "hive",
# schema = "analytics",
# auth = trino_auth_jwt(Sys.getenv("TRINO_TOKEN")),
# timeout = 30,
# query_max_run_time = "5m"
# )
## -----------------------------------------------------------------------------
# dbGetQuery(con, "SELECT 9007199254740993 AS id")$id
# #> integer64
# #> [1] 9007199254740993
## -----------------------------------------------------------------------------
# library(dplyr)
#
# tbl(con, "sales") |>
# filter(year == 2026) |>
# group_by(region) |>
# summarise(total = sum(amount, na.rm = TRUE)) |>
# collect()
## -----------------------------------------------------------------------------
# dbListTables(con)
# dbListFields(con, "sales")
# dbExistsTable(con, "sales")
# dbGetInfo(con)$db.version
## -----------------------------------------------------------------------------
# con <- dbConnect(
# Trino(),
# host = "http://localhost",
# port = 8080,
# catalog = "hive",
# schema = "default",
# extra.headers = list("X-Trino-Session" = "query_max_run_time=2h")
# )
## -----------------------------------------------------------------------------
# dbDisconnect(con)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.