ODBC Connectivity
by Brian Ripley
Department of Statistics, University of Oxford
ripley@stats.ox.ac.uk
September 16, 2021
Package RODBC implements ODBC database connectivity. It was originally written by
Michael Lapsley (St George’s Medical School, University of London) in the early days of R
(1999), but after he disappeared in 2002, it was rescued and since much extended by Brian
Ripley. Version 1.0-1 was released in January 2003, and RODBC is nowadays a mature
and much-used platform for interfacing R to database systems.
Thanks to Marc Schwartz for contributing some of the experiences here. See also the
archives of the R-sig-db mailing list.
1 ODBC Concepts
ODBC aims to provide a common API for access to SQL
1
-based database management
systems (DBMSs) such as MySQL
2
, PostgreSQL, Microsoft Access and SQL Server, DB2,
Oracle and SQLite. It originated on Windows in the early 1990s, but ODBC driver man-
agers unixODBC and iODBC are nowadays available on a wide range of platforms (and iODBC
is used by macOS. The connection to the particular DBMS needs an ODBC driver: these
may come with the DBMS or the ODBC driver manager or be provided separately by
the DBMS developers, and there are third-party
3
developers such as Actual Technologies,
Easysoft and OpenLink. (This means that for some DBMSs there are several different
ODBC drivers available, and they can behave differently.)
Microsoft provides drivers on Windows for non-SQL database systems such as DBase and
FoxPro, and even for flat files and Excel spreadsheets. Actual Technologies sell a driver
for macOS that covers (some) Excel spreadsheets and flat files.
A connection to a specific database is called a Data Source Name or DSN (see https:
//en.wikipedia.org/wiki/Database_Source_Name). See Appendix B for how to set up
DSNs on your system. One of the greatest advantages of ODBC is that it is a cross-
platform client-server design, so it is common to run R on a personal computer and access
data on a remote server whose OS may not even be known to the end user. This does
1
SQL is a language for querying and managing data in databases—see https://en.wikipedia.org/
wiki/SQL.
2
and its fork, MariaDB
3
but there are close links between unixODBC and Easysoft, and iODBC and OpenLink.
1
评论0