Zotero Library Database - item_id changes over time?

I had to export a Zotero library items back in 2015 and was using the item_id as the unique identifier in my database. Due to some issues in the server where the data was being imported I had to redo the exportation, only to realize the item_id had changed which resulted in conflicts with other relationships. Im assuming that Zotero updated the item_id automatically (maybe for organizational reasons, fragmentation, etc).
I am not quite familiarized with Zotero and it wasn't me making the library initial configuration.

Is this the default behaviour of Zotero or can it be configured to preserve the original item_id? And if this is the only way to go, is there a unique field for the items that stays the same over time?
  • The item_id is unique and stable, but it doesn't get preserved during export/import and there's no other field that does (generally export/import to the same database is discouraged for this and other reasons).
  • Thanks for the reply. Sorry I didn't fully understand the explanation. How is it unique and stable but doesn't get preserved between exports? Is it only generated at exportation time? Otherwise if it is stable then it should never change right?Regardless of the data being exported or not.
  • maybe I misunderstood -- I thought you had recreated the database by exporting and re-importing items. That creates de-facto new items with a new item_id.

    But also - the item_id I'm talking about isn't in standard export formats I believe, so you may be talking about something else?

  • What I did was dumping the database items in the zotero.sqlite file in my local user directory using the sqlite tool.

    Example:

    c:\users\xpto\sqlite\sqlite-tools-win32-x86-3250100\sqlite3.exe c:\users\xpto\Zotero\zotero.sqlite
    >.output zotero_dump.sql
    >.dump

    This generates the SQL file from where I import the data. In this file there is an items table that contains the item_id as the primary key. This ID is what changes between exports. Maybe I should be exporting the data directly from your API? Is there an easy way to do so?
  • Maybe the item_id in the local file is only unique locally? And in your server the ID is different?
  • The item id isn't globally unique. The item key is globally unique when combined with a userID or groupID.
  • Neither the userID or groupID is being provided by this export. However the key column is present on the items table and it is unique in my local export, but not globally unless it's combined with one of those right?
  • I'm not sure why you're calling an SQL dump an "export" — running manual commands against the database obviously isn't a supported export method, and you're pretty much on your own for working with the raw data.

    userID and groupID are both in the database (if this database has ever been synced), but if this is just a single library you don't need to worry about them and can rely on the item key alone to uniquely identify an item in any synced versions of that library.

This is an old discussion that has not been active in a long time. Before commenting here, you should strongly consider starting a new discussion instead. If you think the content of this discussion is still relevant, you can link to it from your new discussion.

Sign In or Register to comment.