View source: R/read_tbl_duckdb.R
| read_tbl_duckdb | R Documentation |
read_tbl_duckdb() reads a table from a DuckDB database file
by attaching the database file and reading the specified table.
The database file is attached to the default duckplyr connection and remains attached for the duration of the R session to support lazy evaluation.
read_tbl_duckdb(
path,
table_name,
...,
schema = "main",
prudence = c("thrifty", "lavish", "stingy")
)
path |
Path to the DuckDB database file. |
table_name |
The name of the table to read. |
... |
These dots are for future extensions and must be empty. |
schema |
The schema name where the table is located. Defaults to |
prudence |
Memory protection, controls if DuckDB may convert intermediate results in DuckDB-managed memory to data frames in R memory.
The default is |
A duckplyr frame, see as_duckdb_tibble() for details.
read_sql_duckdb(), db_exec()
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.