Skip to contents

Opens the local zotero.sqlite database in read-only mode. Local records can lag the Web API until the desktop client synchronizes, and WAL mode can make recent local changes temporarily unavailable to another reader.

Usage

zotLocalQuery(
  sql,
  params = list(),
  path = file.path(Sys.getenv("HOME"), "Zotero", "zotero.sqlite")
)

Arguments

sql

One read-only SQL statement.

params

Positional query parameters.

path

Database file (default: the standard Zotero location).

Value

Query result as a data.table.

Details

The database connection is opened with SQLite's read-only flag and closed when the query finishes. zotLocalQuery() does not copy or modify the desktop database. The caller remains responsible for supplying a read-only SQL statement. The default path is ~/Zotero/zotero.sqlite; pass path explicitly for a portable installation or a custom Zotero data directory.

Examples

Path <- tempfile(fileext = ".sqlite")
Connection <- DBI::dbConnect(RSQLite::SQLite(), Path)
DBI::dbWriteTable(Connection, "items", data.frame(key = c("A", "B")))
DBI::dbDisconnect(Connection)
zotLocalQuery("SELECT key FROM items ORDER BY key", path = Path)
#>       key
#>    <char>
#> 1:      A
#> 2:      B
unlink(Path)