Automatic export / access to Zotero's sqlite3 database file for building custom tools

73 views
Skip to first unread message

Ralf Ebert

unread,
Mar 25, 2020, 4:02:25 PM3/25/20
to zotero-dev
Hi,

I'd like to build a script for working with the contents in my Zotero library. What I am looking for is for ways to read the information in the library from a local program / custom script.

My attempts so far:

1. The export from the UI seems usable, especially the CSV one seems to have all the information in a very accessible format. Is there a way to export such a file by executing a command line tool? Or to configure Zotero in a way to export one regularly automatically?

2. I could also query Zoteros sqlite3 database. I just tried to build a query to fetch the records and this seems doable ([1] example query). The problem is, when Zotero is running, the database is locked so not even read-only access is allowed. I want to be able to fetch the information with Zotero running. Sqlite3 seems to have a shared mode for that[2], where other processes are allowed to read. Is there a way to configure Zotero in a way to use that mode so the database can be accessed?

I guess it's pretty special inquiry, but it would be super neat if I could access my Zotero library and build custom tools around it. Thanks for any hints for making that happen,

Greetings,

Ralf

------------

[1]
  select
    itemId,
    key,
    (select typename from itemTypes where itemTypes.itemTypeID=items.itemTypeID) as type, (select value from itemDataValues where valueID = (select valueID from itemData where itemID=items.itemID and fieldID=(select fieldID from fields where fieldName="title"))) as title,
    (select itemId is not null from deletedItems where deletedItems.itemID=items.itemID) as deleted
  from items
  where
    deleted is null
    and type!='attachment'
    and type!='note';

[2] https://www.sqlite.org/lockingv3.html

Ralf Ebert

unread,
Mar 27, 2020, 6:41:11 AM3/27/20
to zotero-dev
Found a solution by reading around in the zothero extension:


If there's a more elegant way to read the Zotero library while it's running, I'd be thankful to get a hint :)

Brenton Wiernik

unread,
Apr 26, 2020, 10:41:44 AM4/26/20
to zotero-dev
The best way to access the Zotero library while the client is running is to use the JavaScript API.
Reply all
Reply to author
Forward
0 new messages