--- title: "Getting Started" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Getting Started} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` ```{r setup} library(dbProject) ``` # Introduction The `dbProject` package provides connection management for local DuckDB databases. It uses `pins` for persistent storage and enables automatic reconnection. ## Creating a dbProject ```{r} # Create project in temp directory project_dir <- tempfile("dbproject_demo") db_path <- file.path(project_dir, "demo.duckdb") proj <- dbProject$new(path = project_dir, dbdir = db_path) proj ``` ## Working with Data ```{r} # Get the connection and add data con <- proj$get_conn() mtcars_tbl <- dplyr::copy_to(con, mtcars, "mtcars", temporary = FALSE, overwrite = TRUE) mtcars_tbl ``` ## Pinning Tables ```{r} proj$pin_write(x = mtcars_tbl, name = "mtcars") proj ``` ## Disconnecting and Reconnecting ```{r} # Disconnect proj$disconnect() proj # Reconnect proj$reconnect() proj ``` ## Reading Pinned Tables ```{r} restored <- proj$pin_read("mtcars") head(restored, 5) ``` ## Cleanup ```{r} proj$disconnect() unlink(project_dir, recursive = TRUE) ```