odbcConnect establishes a connection to the dsn, and
odbcDriverConnect allows a more flexible specification via a
connection string. odbcConnect uses the connection string
"DSN=dsn;UID=uid;PWD=pwd", omitting the last two comments if
they are empty. See the examples for other uses of connection strings.#ifdef windows
Under the Windows GUI, specifying an incomplete connection, for
example the default "", will bring up a dialog box to complete the
information required. (This does not work from Rterm.exe
unless a driver is specified, a Windows restriction.)
#endif
For databases that translate table and column names the case must be
set as appropriate. Allowable values are "nochange",
"toupper" and "tolower" as well as the names of databases
where the behaviour is known to us (currently "mysql" (which
maps to lower case on Windows but not on Linux),
"postgresql" (lower), "oracle" (upper) and
"msaccess" (nochange)). If case is not specified, the
default is "nochange" unless the appropriate value can be
figured out from the DBMS name reported by the ODBC driver.
#ifdef windows
(The DBase driver is unusual: it preserves names on reading, but
converts both table and column names to upper case on writing, and
truncates table names to 8 characters. RODBC does not attempt to do
any mapping for that driver.)
#endif
Function odbcReConnect re-connects to a database using the
settings of an existing (and presumably now closed) channel object.
Arguments case and believeNRows are taken from the
object, but can be overridden by supplying those arguments.
#ifdef windows
odbcConnectAccess, odbcConnectDbase and
odbcConnectExcel are convenience wrappers to generate
connection strings for those file types. The files given can be
relative to the Rworking directory or absolute paths (and it seems
also relative to the user's home directory). Note: they will
only work with English versions of the Microsoft drivers, which may or
may not be installed in other locales. The file name can be omitted
which will bring up a dialog box to search for a file.
#endif
If it is possible to set the DBMS to communicate in the character set
of the Rsession then this should be done. For example, MySQL
can set the communication character set via SQL, e.g.
SET NAMES 'utf8'.