Skip to content

dag-hammarskjold-library/dlx-dl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

pip install git+https://github.com/dag-hammarskjold-library/dlx-dl

Usage

From the command line:

dlx-dl-export --help
dlx-dl-sync --help

From Python:

from dlx_dl.scripts import export, sync

export.run(help=True)
sync.run(help=True)

Notes

  • These scripts can be run from the command line for ad hoc operations, or as Python functions for use in scripts or AWS Lambda.
  • When submitting records to DL using the API, the result is printed to STDOUT.
  • Only exports using the API are logged in the database

Running as Python function

To run the scripts as Python functions, import the scripts as modules from dlx_dl.scripts and pass the arguments specified in --help to the run() function as normal Python keyword arguments.

Python:

from dlx_dl.scripts import export

export.run(source='export_id', type='bib', id=1, xml='output.xml')

export.run(source='export_id', type='bib', id=1, use_api=True)

Command line examples

Preview (display in console) records that meet export criteria and quit

$ dlx-dl-export --source=export_id --type=bib --modified_within=3600 --preview

Write single record to DL by ID

$ dlx-dl-export --source=export_id --type=bib --id=1 --use_api

Write records to DL from a list of IDs

$ dlx-dl-export --source=export_id --type=bib --list=ids.txt --use_api

Write records to file

$ dlx-dl-export --source=export_id --type=bib --ids 1 2 3 --xml=output.xml