1
1
Fork
You've already forked dbat
1
R database attach
  • R 100%
Barry Rowlingson c7ad74dbec better readme
2026年03月12日 09:54:57 +00:00
man masstodon driven dev 2026年03月10日 20:52:48 -04:00
R masstodon driven dev 2026年03月10日 20:52:48 -04:00
DESCRIPTION masstodon driven dev 2026年03月10日 20:52:48 -04:00
NAMESPACE masstodon driven dev 2026年03月10日 20:52:48 -04:00
README.md better readme 2026年03月12日 09:54:57 +00:00

dbat

Simple package with one function, dbat that takes a DBI connection object and makes all tables and views from the connection visible on the search path. It uses R's makeActiveBinding function so that the data is only loaded when the R object is fetched, which is very inefficient for large data used multiple times.

Examples:

con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
DBI::dbWriteTable(con, "db_mtcars", mtcars)
dbat(con)

At this point, db_mtcars is an R object that is on the search path (probably position 2, as "e", which I should make nicer)

search()
ls(pos=2)
head(db_mtcars)

If you want to do lots of things with this data frame then you probably want to read it into memory once to your global environment.

my_db_mtcars = db_mtcars

Disconnecting the database connection breaks the object, but your copy in your global environment is fine. I should make this clean up better.

DBI::dbDisconnect(con)
### with the connection closed, this then breaks...
head(db_mtcars)

Install it:

devtools::install_git(url ="https://codeberg.org/browlingson/dbat/")

https://codeberg.org/browlingson/dbat