Module zotero

Source
Expand description

Zotero SQLite database reader.

§Zotero’s EAV schema

Zotero uses an Entity-Attribute-Value pattern for item metadata:

items (itemID, key, itemTypeID, dateAdded, dateModified)
  └── itemData (itemID, fieldID, valueID)
        └── itemDataValues (valueID, value)
              └── fields (fieldID, fieldName)

This means getting an item’s title requires a 3-table JOIN: items → itemData → itemDataValues, filtered by fieldID for “title”.

Similarly, creators, tags, and attachments are stored in separate tables linked by itemID.

§Performance

The database is ~71MB with ~2700 items. All queries use prepared statements (prepare_cached) and the entire database fits in the OS page cache after first access. Expected latency: <1ms for single-item lookups, <10ms for full-table scans (search).

§Filtering conventions

  • Always exclude deleted items: itemID NOT IN (SELECT itemID FROM deletedItems)
  • Always filter to personal library: libraryID = 1
  • Exclude attachments and notes when listing “real” items: itemTypeID NOT IN (SELECT itemTypeID FROM itemTypes WHERE typeName IN ('attachment', 'note', 'annotation'))

Structs§

Attachment
Collection
Creator
ZoteroDb
Read-only connection to Zotero’s main SQLite database.
ZoteroItem
A Zotero library item with all its metadata assembled from the EAV schema.