This is an old revision of the document!


Direct Access to the Zotero SQLite Database

While it is generally preferable to access Zotero library data via either the Web API or JavaScript API, it is also possible to directly access the SQLite database of the Zotero client using a SQLite client, library or third-party tool.

Zotero uses mozStorage, a database API backed by the SQLite database engine, offering the power of a relational database system within the Mozilla development environment. All system data and item metadata is stored in an SQLite database, zotero.sqlite, within the zotero directory. If the DB doesn’t exist at browser startup, a new one is created from the files system.sql, scrapers.sql and userdata.sql in the extension root, which are then used only during schema updates. (TODO: scrapers.sql no longer exists in Zotero 2.x, so this has to be updated). Zotero creates a copy of the Zotero database at every shutdown and stores it as zotero.sqlite.bak in the same directory.

When externally accessing the SQLite database (this includes access via the mozStorage API), one should be extremely careful to avoid database corruption. Corruption can easily occur when modifying the database while Firefox is running, as mozStorage caching breaks the normal SQLite file-locking that allows for safe concurrent file access. Even if Firefox is shut down before accessing the database file, modifying the database bypasses data validation and referential integrity checks performed by Zotero or the Zotero server when an API is used. For this reason, access the database as read-only if possible.

Also be aware that the SQLite database structure can change between Zotero releases.

dev/client_coding/direct_sqlite_database_access.1303053740.txt.gz · Last modified: 2011/04/17 11:22 by rmzelle