Opens a SQLite database file, executes a SQL query, and returns the result
as a tidylearn_data object. The connection is automatically closed
when done. Requires DBI and RSQLite.
Arguments
- path
Path to a SQLite database file (
.sqliteor.db).- query
A SQL query string.
- ...
Additional arguments passed to
DBI::dbGetQuery().
Examples
# RSQLite imports DBI, so both are available here
path <- tempfile(fileext = ".sqlite")
conn <- DBI::dbConnect(RSQLite::SQLite(), path)
DBI::dbWriteTable(conn, "cars", mtcars)
DBI::dbDisconnect(conn)
tl_read_sqlite(path, "SELECT mpg, cyl, hp FROM cars WHERE cyl = 6")
#> -- tidylearn data ---------
#> Source: /tmp/Rtmp5pHJ7J/file1ab363729.sqlite
#> Format: sqlite
#> Read at: 2026-10-09 07:12:12
#>
#> # A tibble: 7 × 3
#> mpg cyl hp
#> * <dbl> <dbl> <dbl>
#> 1 21 6 110
#> 2 21 6 110
#> 3 21.4 6 110
#> 4 18.1 6 105
#> 5 19.2 6 123
#> 6 17.8 6 123
#> 7 19.7 6 175
unlink(path)
