File: sqlData.Rd

package info (click to toggle)
dbi 1.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,004 kB
  • sloc: makefile: 2
file content (54 lines) | stat: -rw-r--r-- 1,776 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sqlData.R
\name{sqlData}
\alias{sqlData}
\title{Convert a data frame into form suitable for upload to an SQL database}
\usage{
sqlData(con, value, row.names = NA, ...)
}
\arguments{
\item{con}{A database connection.}

\item{value}{A data frame}

\item{row.names}{Either \code{TRUE}, \code{FALSE}, \code{NA} or a string.

If \code{TRUE}, always translate row names to a column called "row_names".
If \code{FALSE}, never translate row names. If \code{NA}, translate
rownames only if they're a character vector.

A string is equivalent to \code{TRUE}, but allows you to override the
default name.

For backward compatibility, \code{NULL} is equivalent to \code{FALSE}.}

\item{...}{Other arguments used by individual methods.}
}
\description{
This is a generic method that coerces R objects into vectors suitable for
upload to the database. The output will vary a little from method to
method depending on whether the main upload device is through a single
SQL string or multiple parameterized queries.
This method is mostly useful for backend implementers.

\Sexpr[results=rd,stage=render]{DBI:::methods_as_rd("sqlData")}
}
\details{
The default method:
\itemize{
\item Converts factors to characters
\item Quotes all strings with \code{\link[=dbQuoteIdentifier]{dbQuoteIdentifier()}}
\item Converts all columns to strings with \code{\link[=dbQuoteLiteral]{dbQuoteLiteral()}}
\item Replaces NA with NULL
}
}
\examples{
\dontshow{if (requireNamespace("RSQLite", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
con <- dbConnect(RSQLite::SQLite(), ":memory:")

sqlData(con, head(iris))
sqlData(con, head(mtcars))

dbDisconnect(con)
\dontshow{\}) # examplesIf}
}