% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/extensions.R
\name{duckdb_consolidate_secrets}
\alias{duckdb_consolidate_secrets}
\title{Consolidate DuckDB secrets into the configured secret directory}
\usage{
duckdb_consolidate_secrets(from = NULL, overwrite = FALSE, ask = interactive())
}
\arguments{
\item{from}{Optional path to an additional source directory to merge in,
or \code{NULL} (the default) for none.}

\item{overwrite}{If \code{FALSE} (the default), the function aborts when any
source file would overwrite an existing secret of the same name at the
target. Set to \code{TRUE} to allow overwriting.}

\item{ask}{If \code{TRUE} (the default in interactive sessions), confirm the
plan before executing it.}
}
\value{
The target directory, invisibly.
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}

Consolidates DuckDB stored secrets from up to three source directories into
the directory currently configured as the target for this R session.
}
\details{
The target directory is the one DuckDB would write to on the next
connection, determined by:

\enumerate{
\item \code{getOption("duckdb.secret_directory")},
\item the \code{DUCKDB_SECRET_DIRECTORY} environment variable,
\item the R-specific default returned by \code{\link[tools:R_user_dir]{tools::R_user_dir()}}.
}

Two source directories are considered automatically:

\itemize{
\item the location shared with the DuckDB CLI and Python client
(\verb{~/.duckdb/stored_secrets}), and
\item the R-specific default location under \code{\link[tools:R_user_dir]{tools::R_user_dir()}}.
}

Whichever of these equals the target is skipped. An additional source
directory may be supplied via \code{from}. Source files are moved into the
target (copied and then removed).

To consistently share secrets with the DuckDB CLI and Python client,
set the \code{duckdb.secret_directory} R option, typically in \verb{~/.Rprofile}:

\preformatted{options(duckdb.secret_directory = "~/.duckdb/stored_secrets")}

Alternatively, set the \code{DUCKDB_SECRET_DIRECTORY} environment variable in
\verb{~/.Renviron} (e.g.\ via \code{usethis::edit_r_environ()}). Either way, then
call \code{duckdb_consolidate_secrets()} to move existing secrets into the
chosen location.

The package emits a startup message when secret files exist in both
the R-default and common locations and neither \code{duckdb.secret_directory}
nor \code{DUCKDB_SECRET_DIRECTORY} is set. Pointing either at any location
both configures the resolver and silences the message.
}
