
Read rows from a Datasette table (or run read-only SQL)
Source:R/ingest_datasette.R
morie_datasette_read.RdFetches /<db>/<table>.json (or /<db>.json?sql=...)
from a Datasette instance and returns the rows as a base R
data.frame. Datasette's SQL surface is read-only by design,
so this cannot mutate the remote database.
Usage
morie_datasette_read(
db,
table = NULL,
sql = NULL,
limit = 1000L,
base_url = NULL,
timeout = 60
)Arguments
- db
Database name as served by the instance.
- table
Table name; ignored when
sqlis given.- sql
Optional read-only SQL string executed against
db.- limit
Row cap forwarded as Datasette's
_size(table mode) or appended asLIMITadvice in SQL mode (default 1000).- base_url
Instance root URL; defaults to the
MORIE_DATASETTE_URLenvironment variable.- timeout
HTTP timeout in seconds.
Examples
if (FALSE) { # nzchar(Sys.getenv("MORIE_DATASETTE_URL"))
dbs <- morie_datasette_databases()
# Peek at the first table of the first database:
tabs <- morie_datasette_read(dbs$name[1],
sql = "SELECT name FROM sqlite_master WHERE type='table' LIMIT 5")
tabs
}