if (FALSE) { # rlang::is_interactive()
# Create a temporary DuckDB database with a table
db_path <- tempfile(fileext = ".duckdb")
con <- DBI::dbConnect(duckdb::duckdb(), db_path)
DBI::dbWriteTable(con, "test_table", data.frame(a = 1:3, b = c("x", "y", "z")))
DBI::dbDisconnect(con)
# Read the table from the database file
df <- read_tbl_duckdb(db_path, "test_table")
print(df)
# Clean up
unlink(db_path)
}
Run the code above in your browser using DataLab