Read-only command-line client for locating, browsing, and querying a local Zotero SQLite database and its PDF annotations.
Important
This codebase is entirely AI-generated. It is useful to me, I hope it might be useful to others, and issues and contributions are welcome.
From a checkout:
uv sync # install project dependencies
uv run zotero-sqlite-tool --help # inspect the CLIFrom a built wheel:
python -m pip install dist/*.whl # install from a built wheel
zotero-sqlite-tool --help # inspect the installed entry pointzotero-sqlite-tool locate-db: detect candidatezotero.sqlitepaths and show the selected default path.- All commands support
--db-pathto override database resolution. - All commands support
--library-idto scope operations to one Zotero library. - All commands support
--textfor compact text output instead of JSON.
zotero-sqlite-tool list-collections: list collection keys, names, paths, and library IDs.zotero-sqlite-tool list-collections --collection <selector>: filter collections by key, name, or path fragment.
zotero-sqlite-tool search-items --query <text>: search titles, metadata, creators, tags, notes, and annotations.zotero-sqlite-tool search-items --collection <selector>: scope search to one collection.zotero-sqlite-tool search-items --include-subcollections: include descendant collections when collection-scoped.zotero-sqlite-tool search-items --any-term: switch from all-terms matching to any-term matching.- Search results are ranked and include matched fields and score metadata.
zotero-sqlite-tool pdf-positions: extract PDF annotation positions and related metadata.zotero-sqlite-tool pdf-positions --item-id <id>: target one parent item by item ID.zotero-sqlite-tool pdf-positions --item-key <key>: target one parent item by Zotero item key.zotero-sqlite-tool pdf-positions --query <text>: either resolve parent items by search query or filter annotations by text/comment content, depending on the selector mode.zotero-sqlite-tool pdf-positions --collection <selector>and--include-subcollections: scope annotation extraction to collection trees.
- The client opens the database read-only.
- The client enables SQLite
query_only. - The client only permits
SELECTandWITHqueries internally.
The CLI resolves zotero.sqlite in this order:
--db-pathZOTERO_DB_PATHZOTERO_DATA_DIR/zotero.sqlite~/Zotero/zotero.sqlite~/.zotero/zotero/*.default*/zotero.sqlite~/.var/app/org.zotero.Zotero/data/Zotero/zotero.sqlite
uv run zotero-sqlite-tool locate-db # find candidate Zotero databases
uv run zotero-sqlite-tool list-collections --collection "machine learning" # filter collection names and paths
uv run zotero-sqlite-tool search-items \ # search item metadata inside one collection tree
--collection "AB12CD34" \
--include-subcollections \
--query "retrieval augmented generation"
uv run zotero-sqlite-tool pdf-positions --item-key "QWERTY12" # extract PDF annotation positionsArch packaging notes live in AUR_VALIDATION.md.
This tool is built for the local Zotero client database and is not affiliated with Zotero.
Credit goes to the Zotero project for the application, schema, and data model this CLI builds on.