diff options
author | Alexander Von Moll <avonmoll@gmail.com> | 2018-10-05 16:28:10 -0400 |
---|---|---|
committer | Alejandro Gallo <aamsgallo@gmail.com> | 2018-10-09 00:03:39 +0200 |
commit | 50188525b329d3e0503284101e78114beb07ddb1 (patch) | |
tree | ccfdf46c0f7143dd0acc9dd0ba18db984d8e1658 | |
parent | ba8ceb6a46f98a692fd53195aae468502f4c6006 (diff) |
Import zotero collections to project
-rwxr-xr-x | examples/scripts/papis-zotero-sql | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/scripts/papis-zotero-sql b/examples/scripts/papis-zotero-sql index f63ee73f..a14fcefd 100755 --- a/examples/scripts/papis-zotero-sql +++ b/examples/scripts/papis-zotero-sql @@ -182,6 +182,24 @@ def getTags(connection, itemId): return {"tags":tags} +def getCollections(connection, itemId): + itemCollectionQuery = """ + SELECT + collections.collectionName + FROM + collections, + collectionItems + WHERE + collectionItems.itemID = {itemID} AND + collections.collectionID = collectionItems.collectionID + """ + collectionCursor = connection.cursor() + collectionCursor.execute(itemCollectionQuery.format(itemID=itemId)) + collections = [] + for collectionRow in collectionCursor: + collections.append(collectionRow[0]) + + return {"project":collections} def cleanItem(item): if item.get("year") is None and item.get("date") is not None: @@ -250,6 +268,7 @@ for row in cursor: item.update(getFields(connection, itemId)) item.update(getCreators(connection, itemId)) item.update(getTags(connection, itemId)) + item.update(getCollections(connection, itemId)) item.update(getFiles(connection, itemId, itemKey)) cleanItem(item) |