DBI

A database interface (DBI) definition for communication between R and RDBMSs

https://github.com/r-dbi/dbi

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    4 of 34 committers (11.8%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.7%) to scientific vocabulary

Keywords

database interface r

Keywords from Contributors

travis-ci package-creation standards pandoc literate-programming rmarkdown tidy-data codecov coverage coverage-report
Last synced: 6 months ago · JSON representation

Repository

A database interface (DBI) definition for communication between R and RDBMSs

Basic Info
  • Host: GitHub
  • Owner: r-dbi
  • License: lgpl-2.1
  • Language: HTML
  • Default Branch: main
  • Homepage: https://dbi.r-dbi.org
  • Size: 18.3 MB
Statistics
  • Stars: 306
  • Watchers: 23
  • Forks: 76
  • Open Issues: 16
  • Releases: 19
Topics
database interface r
Created over 12 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Security

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# DBI


[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![rcc](https://github.com/r-dbi/DBI/workflows/rcc/badge.svg)](https://github.com/r-dbi/DBI/actions)
[![Coverage Status](https://codecov.io/gh/r-dbi/DBI/branch/main/graph/badge.svg)](https://app.codecov.io/github/r-dbi/DBI?branch=main)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/DBI)](https://cran.r-project.org/package=DBI)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/1882/badge)](https://bestpractices.coreinfrastructure.org/projects/1882)


The DBI package helps connecting R to database management systems (DBMS).
DBI separates the connectivity to the DBMS into a "front-end" and a "back-end".
The package defines an interface that is implemented by *DBI backends* such as:

- [RPostgres](https://rpostgres.r-dbi.org),
- [RMariaDB](https://rmariadb.r-dbi.org),
- [RSQLite](https://rsqlite.r-dbi.org),
- [odbc](https://github.com/r-dbi/odbc),
- [bigrquery](https://github.com/r-dbi/bigrquery),

and many more, see the [list of backends](https://github.com/r-dbi/backends#readme).
R scripts and packages use DBI to access various databases through their DBI backends.

The interface defines a small set of classes and methods similar in spirit to Perl's [DBI](https://dbi.perl.org/), Java's JDBC, Python's [DB-API](https://www.python.org/dev/peps/pep-0249/), and Microsoft's [ODBC](https://en.wikipedia.org/wiki/ODBC).
It supports the following operations:

* connect/disconnect to the DBMS
* create and execute statements in the DBMS
* extract results/output from statements
* error/exception handling
* information (meta-data) from database objects
* transaction management (optional)

## Installation

Most users who want to access a database do not need to install DBI directly.
It will be installed automatically when you install one of the database backends:

- [RPostgres](https://rpostgres.r-dbi.org) for PostgreSQL,
- [RMariaDB](https://rmariadb.r-dbi.org) for MariaDB or MySQL,
- [RSQLite](https://rsqlite.r-dbi.org) for SQLite,
- [odbc](https://github.com/r-dbi/odbc) for databases that you can access via [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity),
- [bigrquery](https://github.com/r-dbi/bigrquery),
- ... .

You can install the released version of DBI from [CRAN](https://CRAN.R-project.org) with:

``` r
install.packages("DBI")
```

And the development version from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("r-dbi/DBI")
```

## Example

The following example illustrates some of the DBI capabilities:

```{r example}
library(DBI)
# Create an ephemeral in-memory RSQLite database
con <- dbConnect(RSQLite::SQLite(), dbname = ":memory:")

dbListTables(con)
dbWriteTable(con, "mtcars", mtcars)
dbListTables(con)

dbListFields(con, "mtcars")
dbReadTable(con, "mtcars")

# You can fetch all results:
res <- dbSendQuery(con, "SELECT * FROM mtcars WHERE cyl = 4")
dbFetch(res)
dbClearResult(res)

# Or a chunk at a time
res <- dbSendQuery(con, "SELECT * FROM mtcars WHERE cyl = 4")
while (!dbHasCompleted(res)) {
  chunk <- dbFetch(res, n = 5)
  print(nrow(chunk))
}
dbClearResult(res)

dbDisconnect(con)
```

## Class structure

There are four main DBI classes.
Three which are each extended by individual database backends:

* `DBIObject`: a common base class for all DBI.

* `DBIDriver`: a base class representing overall DBMS properties.
  Typically generator functions instantiate the driver objects like `RSQLite()`,
  `RPostgreSQL()`, `RMySQL()` etc.

* `DBIConnection`: represents a connection to a specific database

* `DBIResult`: the result of a DBMS query or statement.

All classes are _virtual_: they cannot be instantiated directly and instead must be subclassed.

## Further Reading

* [Databases using R](https://db.rstudio.com/) describes the tools and best practices in this ecosystem.

* The [DBI project site](https://r-dbi.org/) hosts a blog where recent developments are presented.

* [A history of DBI](https://dbi.r-dbi.org/articles/DBI-history.html) by David James, the driving force behind the development of DBI, and many of the packages that implement it.

---

Please note that the _DBI_ project is released with a [Contributor Code of Conduct](https://dbi.r-dbi.org/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.

Owner

  • Name: r-dbi
  • Login: r-dbi
  • Kind: organization

R + databases

GitHub Events

Total
  • Issues event: 5
  • Watch event: 12
  • Delete event: 27
  • Issue comment event: 22
  • Push event: 99
  • Pull request event: 58
  • Fork event: 1
  • Create event: 46
Last Year
  • Issues event: 5
  • Watch event: 12
  • Delete event: 27
  • Issue comment event: 22
  • Push event: 99
  • Pull request event: 58
  • Fork event: 1
  • Create event: 46

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 1,629
  • Total Committers: 34
  • Avg Commits per committer: 47.912
  • Development Distribution Score (DDS): 0.252
Past Year
  • Commits: 59
  • Committers: 3
  • Avg Commits per committer: 19.667
  • Development Distribution Score (DDS): 0.169
Top Committers
Name Email Commits
Kirill Müller k****r@m****g 1,219
hadley h****m@g****m 131
Kirill Müller k****r@i****h 118
Hannes Muehleisen h****s@m****g 26
sethf s****f@d****5 19
Barbara Borges Ribeiro b****o@g****m 15
Nicolas Bennett 3****n 15
github-actions[bot] 4****] 9
Indrajeet Patil p****e@g****m 8
rgentlem r****m@d****5 7
jawond j****k@g****m 7
Maëlle Salmon m****n@y****e 7
eauleaf e****f@g****m 6
Kun Ren r****n@o****m 5
Katharina Brunner m****l@k****e 5
Will Beasley w****y@h****m 4
Nicolas Bennett n****t@i****m 4
Charles Bailey b****c@e****u 3
Michael Chirico m****4@g****m 2
Sean Raffuse r****n@g****m 2
Salim B g****t@s****e 2
Robert r****g@g****m 2
Hiroaki Yutani y****i@g****m 2
GitHub n****y@g****m 1
Jim Hester j****r@g****m 1
Juergen Altfeld R@a****e 1
daj025@gmail.com d****5@g****m@d****5 1
Anh Le a****3@d****u 1
Andrew Collier a****w@e****z 1
Michael Sumner m****r@g****m 1
and 4 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 88
  • Total pull requests: 164
  • Average time to close issues: 6 months
  • Average time to close pull requests: 16 days
  • Total issue authors: 55
  • Total pull request authors: 12
  • Average comments per issue: 2.77
  • Average comments per pull request: 0.97
  • Merged pull requests: 143
  • Bot issues: 0
  • Bot pull requests: 22
Past Year
  • Issues: 5
  • Pull requests: 57
  • Average time to close issues: 19 minutes
  • Average time to close pull requests: about 23 hours
  • Issue authors: 4
  • Pull request authors: 3
  • Average comments per issue: 0.4
  • Average comments per pull request: 0.02
  • Merged pull requests: 51
  • Bot issues: 0
  • Bot pull requests: 21
Top Authors
Issue Authors
  • krlmlr (21)
  • mmuurr (3)
  • mgirlich (3)
  • pnacht (2)
  • r2evans (2)
  • eitsupi (2)
  • GitHunter0 (2)
  • hadley (2)
  • MichaelChirico (2)
  • eriksquires (2)
  • asadow (2)
  • rnorberg (2)
  • colearendt (1)
  • VictorYammouni (1)
  • bborgesr (1)
Pull Request Authors
  • krlmlr (120)
  • github-actions[bot] (22)
  • maelle (6)
  • MichaelChirico (4)
  • hadley (3)
  • salim-b (2)
  • jawond (2)
  • rnorberg (1)
  • nbenn (1)
  • eauleaf (1)
  • renkun-ken (1)
  • datawookie (1)
Top Labels
Issue Labels
docs (22) help wanted (5) bug (4) feature (2) action:enhance (1)
Pull Request Labels
mergequeue (23) CRAN release :station: (10) blocked (7) mergequeue-priority (4)

Packages

  • Total packages: 4
  • Total downloads:
    • cran 638,930 last-month
  • Total docker downloads: 121,994,290
  • Total dependent packages: 384
    (may contain duplicates)
  • Total dependent repositories: 1,464
    (may contain duplicates)
  • Total versions: 63
  • Total maintainers: 1
cran.r-project.org: DBI

R Database Interface

  • Versions: 38
  • Dependent Packages: 346
  • Dependent Repositories: 1,396
  • Downloads: 638,930 Last month
  • Docker Downloads: 121,994,290
Rankings
Dependent repos count: 0.3%
Dependent packages count: 0.3%
Downloads: 0.4%
Forks count: 1.0%
Stargazers count: 1.5%
Average: 3.5%
Docker downloads count: 17.3%
Maintainers (1)
Last synced: 6 months ago
proxy.golang.org: github.com/r-dbi/dbi
  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.7%
Dependent repos count: 5.8%
Last synced: 6 months ago
proxy.golang.org: github.com/r-dbi/DBI
  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.7%
Dependent repos count: 5.8%
Last synced: 6 months ago
conda-forge.org: r-dbi
  • Versions: 7
  • Dependent Packages: 38
  • Dependent Repositories: 68
Rankings
Dependent packages count: 1.8%
Dependent repos count: 4.2%
Average: 12.8%
Forks count: 21.6%
Stargazers count: 23.6%
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.0.0 depends
  • methods * depends
  • DBItest * suggests
  • RMariaDB * suggests
  • RSQLite >= 1.1 suggests
  • blob * suggests
  • covr * suggests
  • dbplyr * suggests
  • downlit * suggests
  • dplyr * suggests
  • glue * suggests
  • hms * suggests
  • knitr * suggests
  • magrittr * suggests
  • rmarkdown * suggests
  • rprojroot * suggests
  • testthat * suggests
  • xml2 * suggests
.github/workflows/R-CMD-check-dev.yaml actions
  • ./.github/workflows/check * composite
  • ./.github/workflows/custom/after-install * composite
  • ./.github/workflows/custom/before-install * composite
  • ./.github/workflows/dep-matrix * composite
  • ./.github/workflows/install * composite
  • ./.github/workflows/rate-limit * composite
  • ./.github/workflows/update-snapshots * composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-r v2 composite
.github/workflows/R-CMD-check.yaml actions
  • ./.github/workflows/check * composite
  • ./.github/workflows/commit * composite
  • ./.github/workflows/custom/after-install * composite
  • ./.github/workflows/custom/before-install * composite
  • ./.github/workflows/git-identity * composite
  • ./.github/workflows/install * composite
  • ./.github/workflows/pkgdown-build * composite
  • ./.github/workflows/pkgdown-deploy * composite
  • ./.github/workflows/rate-limit * composite
  • ./.github/workflows/roxygenize * composite
  • ./.github/workflows/style * composite
  • ./.github/workflows/update-snapshots * composite
  • actions/checkout v3 composite
.github/workflows/check/action.yml actions
  • actions/upload-artifact main composite
  • r-lib/actions/check-r-package v2 composite
.github/workflows/custom/after-install/action.yml actions
  • ankane/setup-mariadb v1 composite
.github/workflows/fledge.yaml actions
  • ./.github/workflows/git-identity * composite
  • ./.github/workflows/install * composite
  • actions/checkout v2 composite
.github/workflows/install/action.yml actions
  • ./.github/workflows/get-extra * composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/lock.yaml actions
  • dessant/lock-threads v2 composite
.github/workflows/pkgdown-deploy/action.yml actions
  • nick-fields/retry v2 composite
.github/workflows/pkgdown.yaml actions
  • ./.github/workflows/custom/after-install * composite
  • ./.github/workflows/custom/before-install * composite
  • ./.github/workflows/git-identity * composite
  • ./.github/workflows/install * composite
  • ./.github/workflows/pkgdown-build * composite
  • ./.github/workflows/pkgdown-deploy * composite
  • ./.github/workflows/rate-limit * composite
  • actions/checkout v3 composite
.github/workflows/pr-commands.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/pr-fetch master composite
  • r-lib/actions/pr-push master composite
  • r-lib/actions/setup-r master composite
.github/workflows/revdep.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact main composite
  • r-lib/actions/setup-pandoc v2 composite
.github/workflows/style/action.yml actions
  • actions/cache v3 composite
.github/workflows/update-snapshots/action.yml actions
  • peter-evans/create-pull-request v4 composite