% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/reader.R
\name{odbc_reader}
\alias{odbc_reader}
\title{Create an ODBC reader}
\usage{
odbc_reader(
  dsn = NULL,
  driver = NULL,
  server = NULL,
  database = NULL,
  uid = NULL,
  pwd = NULL,
  ...,
  connection_string = NULL
)
}
\arguments{
\item{dsn}{Name of a data source configured in \code{odbc.ini} / \code{odbcinst.ini}.}

\item{driver}{ODBC driver name (e.g. \code{"{PostgreSQL}"}, \code{"{Snowflake}"}).
Curly brackets are optional.}

\item{server, database, uid, pwd}{Common ODBC parameters.}

\item{...}{Additional named \code{key = value} parameters appended to the
connection string (e.g. \code{Port = 5432}, \code{Warehouse = "COMPUTE_WH"}).}

\item{connection_string}{A full ODBC connection string, e.g.
\code{"Driver={PostgreSQL};Server=localhost;Database=mydb;UID=user;PWD=pass"}.
A leading \verb{odbc://} is accepted and stripped.}
}
\value{
A \code{Reader} object.
}
\description{
Creates a connection to a database through an ODBC driver. Can execute SQL
queries and, where the backend supports it, register R data frames as
temporary tables. Requires an ODBC driver manager (unixODBC/iODBC on Unix,
built into Windows) and the appropriate ODBC driver for the target database
to be installed.
}
\details{
Either pass a full ODBC connection string via \code{connection_string}, or supply
named components (\code{dsn}, \code{driver}, \code{server}, \code{database}, \code{uid}, \code{pwd}, plus
any extra \code{key = value} pairs in \code{...}) and they will be assembled into a
connection string. If \code{connection_string} is supplied, the other named
arguments are ignored.
}
\section{Credentials}{

Connection strings are stored in-memory for the life of the reader. Prefer
configuring credentials through a DSN, \verb{~/.odbc.ini}, or environment
variables rather than hard-coding passwords in scripts.
}

\examples{
\dontrun{
# Using a preconfigured DSN
reader <- odbc_reader(dsn = "mydsn")

# Building a connection string from components
reader <- odbc_reader(
  driver = "{PostgreSQL}",
  server = "localhost",
  database = "mydb",
  uid = "user",
  pwd = "secret",
  Port = 5432
)

# Passing a full connection string
reader <- odbc_reader("Driver={SQLite3};Database=:memory:")
}

}
\seealso{
Other readers: 
\code{\link{custom_reader}()},
\code{\link{duckdb_reader}()},
\code{\link{snowflake_reader}()}
}
\concept{readers}
