% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/with-dialect.R
\name{with_dialect}
\alias{with_dialect}
\title{Override the SQL dialect for a connection}
\usage{
with_dialect(con, dialect)
}
\arguments{
\item{con}{A database connection (class \code{DBIConnection}).}

\item{dialect}{A dialect object created by a \verb{dialect_*()} function
(e.g., \code{\link[=dialect_postgres]{dialect_postgres()}}, \code{\link[=dialect_sqlite]{dialect_sqlite()}}).}
}
\value{
A connection object that uses the specified dialect for SQL
generation.
}
\description{
\code{with_dialect()} overrides the default dialect assigned to a connection.
This is useful when dbplyr guesses the dialect incorrectly, which is most
likely to occur with ODBC/JDBC/ADBC backends.
}
\examples{
# Wrap an in-memory SQLite connection to use Postgres dialect
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
pg_con <- with_dialect(con, dialect_postgres())

# SQL generation uses Postgres syntax
lf <- lazy_frame(x = 1, con = pg_con)
lf |> dplyr::mutate(y = sd(x))

DBI::dbDisconnect(con)
}
