1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/dbplyr.R
3\name{backend_dbplyr}
4\alias{backend_dbplyr}
5\alias{db_desc}
6\alias{sql_translate_env}
7\alias{db_list_tables}
8\alias{db_has_table}
9\alias{db_data_type}
10\alias{db_save_query}
11\alias{db_begin}
12\alias{db_commit}
13\alias{db_rollback}
14\alias{db_write_table}
15\alias{db_create_table}
16\alias{db_insert_into}
17\alias{db_create_indexes}
18\alias{db_create_index}
19\alias{db_drop_table}
20\alias{db_analyze}
21\alias{db_explain}
22\alias{db_query_fields}
23\alias{db_query_rows}
24\alias{sql_select}
25\alias{sql_subquery}
26\alias{sql_join}
27\alias{sql_semi_join}
28\alias{sql_set_op}
29\alias{sql_escape_string}
30\alias{sql_escape_ident}
31\title{Database and SQL generics.}
32\usage{
33db_desc(x)
34
35sql_translate_env(con)
36
37db_list_tables(con)
38
39db_has_table(con, table)
40
41db_data_type(con, fields)
42
43db_save_query(con, sql, name, temporary = TRUE, ...)
44
45db_begin(con, ...)
46
47db_commit(con, ...)
48
49db_rollback(con, ...)
50
51db_write_table(con, table, types, values, temporary = FALSE, ...)
52
53db_create_table(con, table, types, temporary = FALSE, ...)
54
55db_insert_into(con, table, values, ...)
56
57db_create_indexes(con, table, indexes = NULL, unique = FALSE, ...)
58
59db_create_index(con, table, columns, name = NULL, unique = FALSE, ...)
60
61db_drop_table(con, table, force = FALSE, ...)
62
63db_analyze(con, table, ...)
64
65db_explain(con, sql, ...)
66
67db_query_fields(con, sql, ...)
68
69db_query_rows(con, sql, ...)
70
71sql_select(
72  con,
73  select,
74  from,
75  where = NULL,
76  group_by = NULL,
77  having = NULL,
78  order_by = NULL,
79  limit = NULL,
80  distinct = FALSE,
81  ...
82)
83
84sql_subquery(con, from, name = random_table_name(), ...)
85
86sql_join(con, x, y, vars, type = "inner", by = NULL, ...)
87
88sql_semi_join(con, x, y, anti = FALSE, by = NULL, ...)
89
90sql_set_op(con, x, y, method)
91
92sql_escape_string(con, x)
93
94sql_escape_ident(con, x)
95}
96\arguments{
97\item{con}{A database connection.}
98
99\item{table}{A string, the table name.}
100
101\item{fields}{A list of fields, as in a data frame.}
102}
103\value{
104Usually a logical value indicating success. Most failures should generate
105an error. However, \code{db_has_table()} should return \code{NA} if
106temporary tables cannot be listed with \code{\link[DBI:dbListTables]{DBI::dbListTables()}} (due to backend
107API limitations for example). As a result, you methods will rely on the
108backend to throw an error if a table exists when it shouldn't.
109}
110\description{
111The \code{sql_} generics are used to build the different types of SQL queries.
112The default implementations in dbplyr generates ANSI 92 compliant SQL.
113The \code{db_} generics execute actions on the database. The default
114implementations in dbplyr typically just call the standard DBI S4
115method.
116}
117\details{
118A few backend methods do not call the standard DBI S4 methods including
119\itemize{
120\item \code{db_data_type()}: Calls \code{\link[DBI:dbDataType]{DBI::dbDataType()}} for every field
121(e.g. data frame column) and returns a vector of corresponding SQL data
122types
123\item \code{db_save_query()}: Builds and executes a
124\verb{CREATE [TEMPORARY] TABLE <table> ...} SQL command.
125\item \code{db_create_index()}: Builds and executes a
126\verb{CREATE INDEX <name> ON <table>} SQL command.
127\item \code{db_drop_table()}: Builds and executes a
128\verb{DROP TABLE [IF EXISTS]  <table>} SQL command.
129\item \code{db_analyze()}: Builds and executes an
130\verb{ANALYZE <table>} SQL command.
131}
132
133Currently, \code{\link[=copy_to]{copy_to()}} is the only user of \code{db_begin()}, \code{db_commit()},
134\code{db_rollback()}, \code{db_write_table()}, \code{db_create_indexes()}, \code{db_drop_table()} and
135\code{db_analyze()}. If you find yourself overriding many of these
136functions it may suggest that you should just override \code{copy_to()}
137instead.
138
139\code{db_create_table()} and \code{db_insert_into()} have been deprecated
140in favour of \code{db_write_table()}.
141}
142\keyword{internal}
143