r-dbi/odbc
r-dbi/odbc has 418 GitHub stars and 119 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-09 16:32 UTC. Last push 2026-10-24.
Connect to ODBC databases (using the DBI interface)
Measured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Originalodbc 
The goal of the odbc package is to provide a DBI-compliant interface to ODBC drivers. This makes it easy to connect databases such as SQL Server, Oracle, Databricks, and Snowflake.
The odbc package is an alternative to
RODBC and
RODBCDBI packages, and is
typically much faster. See vignette("benchmarks") to learn more.
Overview
The odbc package is one piece of the R interface to databases with support for ODBC:
<img src=“man/figures/whole-game.png” alt=“A diagram containing four boxes with arrows linking each pointing left to right. The boxes read, in order,”R interface,” “driver manager,” “ODBC driver,” and “DBMS.” The left-most box, R interface, contains three smaller components, labeled “dbplyr,” “DBI,” and “odbc.”” width=“1489” />
Support for a given DBMS is provided by an ODBC driver, which defines how to interact with that DBMS using the standardized syntax of ODBC and SQL. Drivers can be downloaded from the DBMS vendor or, if you’re a Posit customer, using the professional drivers.
Drivers are managed by a driver manager, which is responsible for
configuring driver locations, and optionally named data sources that
describe how to connect to a specific database. Windows is bundled with
a driver manager, while MacOS and Linux require installation of
unixODBC. Drivers often require some manual
configuration; see vignette("setup") for details.
In the R interface, the DBI package provides a front-end while odbc implements a back-end to communicate with the driver manager. The odbc package is built on top of the nanodbc C++ library. To interface with DBMSs using R and odbc:
<img src=“man/figures/r-interface.png” alt=“A high-level workflow for using the R interface in 3 steps. In step 1, configure drivers and data sources, the functions odbcListDrivers() and odbcListDataSources() help to interface with the driver manager. In step 2, the dbConnect() function, called with the first argument odbc(), connects to a database using the specified ODBC driver to create a connection object”con.” Finally, in step 3, that connection object can be passed to various functions to retrieve information on database structure, iteratively develop queries, and query data objects.” width=“1302” />
You might also use the dbplyr package to automatically generate SQL from your dplyr code.
Installation
Install the latest release of odbc from CRAN with the following code:
install.packages("odbc")
To get a bug fix or to use a feature from the development version, you can install the development version of odbc from GitHub:
# install.packages("pak")
pak::pak("r-dbi/odbc")
Usage
To use odbc, begin by creating a database connection, which might look something like this:
library(DBI)
con <- dbConnect(
odbc::odbc(),
driver = "SQL Server",
server = "my-server",
database = "my-database",
uid = "my-username",
pwd = rstudioapi::askForPassword("Database password")
)
(See vignette("setup") for examples of connecting to a variety of
databases.)
dbListTables() is used for listing all existing tables in a database.
dbListTables(con)
dbReadTable() will read a full table into an R data.frame().
data <- dbReadTable(con, "flights")
dbWriteTable() will write an R data.frame() to an SQL table.
dbWriteTable(con, "iris", iris)
dbGetQuery() will submit a SQL query and fetch the results:
df <- dbGetQuery(
con,
"SELECT flight, tailnum, origin FROM flights ORDER BY origin"
)
It is also possible to submit the query and fetch separately with
dbSendQuery() and dbFetch(). This allows you to use the n argument
to dbFetch() to iterate over results that would otherwise be too large
to fit in memory.
Explore related projects
Asabeneh/30-Days-Of-Python
The 30 Days of Python programming challenge is a step-by-step guide to learn the Python programming language in 30 days. This challenge may take more than 100 days. Follow your own pace. These videos may help too: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,423 starsgrafana/grafana
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
77,790 starsredis/redis
For developers, who are building real-time data-driven applications, Redis is the preferred, fastest, and most feature-rich cache, data structure server, and document and vector query engine.
77,309 starsapache/superset
Apache Superset is a Data Visualization and Data Exploration Platform
75,455 stars