dbReadTable-ODBCConnection-character-method: Convenience functions for importing/exporting DBMS tables

Description Usage Arguments Value Note Examples

Description

These functions mimic their R/S-Plus counterpart get, assign, exists, remove, and objects, except that they generate code that gets remotely executed in a database engine.

Usage

1
2
3
## S4 method for signature 'ODBCConnection,character'
dbReadTable(conn, name, row.names = NA,
  check.names = TRUE, select.cols = "*")

Arguments

conn

a ODBCConnection object, produced by dbConnect

name

a character string specifying a table name.

row.names

a character string specifying a table name.

check.names

If TRUE, the default, column names will be converted to valid R identifiers.

select.cols

A SQL statement (in the form of a character vector of length 1) giving the columns to select. E.g. "*" selects all columns, "x,y,z" selects three columns named as listed.

Value

A data.frame in the case of dbReadTable; otherwise a logical indicating whether the operation was successful.

Note

Note that the data.frame returned by dbReadTable only has primitive data, e.g., it does not coerce character data to factors.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
library(DBI)
con <- dbConnect(RODBCDBI::ODBC(), dsn="test", user="sa", password="Password12!")
dbWriteTable(con, "mtcars", mtcars, overwrite=TRUE)
dbReadTable(con, "mtcars")
dbGetQuery(con, "SELECT * FROM mtcars WHERE cyl = 8")

# Supress row names
dbReadTable(con, "mtcars", row.names = FALSE)
dbGetQuery(con, "SELECT * FROM mtcars WHERE cyl = 8", row.names = FALSE)

dbDisconnect(con)

## End(Not run)

RODBCDBI documentation built on May 2, 2019, 5:56 a.m.