RODBC {RODBC} | R Documentation |
RODBC
implements ODBC database connectivity with compliant
databases where drivers exist on the host system.
sqlCopy(channel, query, destination, destchannel = channel, verbose = FALSE, errors = TRUE, ...) sqlCopyTable(channel, srctable, desttable, destchannel = channel, verbose = FALSE, errors = TRUE)
channel, destchannel |
connection handle as returned by
odbcConnect . |
query |
any valid SQL statement |
destination, srctable, desttable |
a database table name accessible from the connected dsn. This should be either a character string or a character vector of length 1. |
verbose |
Display statements as they are sent to the server? |
errors |
if TRUE halt and display error, else return -1. |
... |
additional arguments to be passed to sqlSave . |
Two groups
of commands are provided. odbc*
commands implement relatively
low level access to the odbc functions of similar name.
sql*
commands are higher level constructs to read, save, copy and
manipulate data between data frames and sql tables. Up to 16 connections
can be open at once to any combination of dsn/hosts.
Writing columns is limited to 255 characters wide.
sqlCopy
as is like sqlQuery
,
but saves the output of query
in table destination
on
channel destchannel
. [Not yet implemented.]
sqlCopyTable
copies the structure of srctable
to desttable
on dsn
destchannel
. This is within the limitations of the ODBC lowest
common denominator. More precise control is possible via
sqlQuery
.
A few functions try to cope with the peculiar way the Excel ODBC driver handles names.
See sqlGetResults
.
Michael Lapsley and Brian Ripley
odbcConnect
, sqlFetch
,
sqlSave
, sqlTables
, odbcGetInfo
## Not run: library(RODBC) data(USArrests) channel <- odbcConnect("test", "", "") # userId and password sqlSave(channel, USArrests, rownames = "State", verbose = TRUE) options(dec=".") # this is the default decimal point sqlQuery(channel, "select State, Murder from USArrests where rape > 30 order by Murder") sqlFetch(channel, "USArrests", rownames = "State") sqlDrop(channel, "USArrests") odbcClose(channel) ## End(Not run)