Files
osdb-1-claude-opusplan/scripts/README_import.md
T
juliaandClaude Sonnet 4.6 e8d48d4fcb feat: import existing publications from XML (story #05)
scripts/import_publications.py imports all osw=1 publications from
03-data/osws.xml — upserts pub rows, loads cover images, scans
03-data/osdb/{pubId}/ for fruit images and PDFs, links matched fruits
by osdb_number. Idempotent re-runs. 17 unit tests. Makefile updated
to include import_publications_test in make test. Added
scripts/README_import.md with run order. Added spec-first rule to
.claude/CLAUDE.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-18 11:47:45 +02:00

1000 B

Import Scripts

Prerequisites

  • Postgres running and migrated (make migrate-up)
  • DATABASE_URL set, e.g.:
    export DATABASE_URL=postgres://user:pass@localhost:5432/osdb
    
  • 03-data/ directory present at repo root
  • psycopg2 installed (pip install psycopg2-binary)

Run Order

Scripts must be run in order — publications import depends on fruits being present.

1. Import fruits

DATABASE_URL=... python3 scripts/import_fruits.py

Imports fruits, synonyms, and fruit images from 03-data/obstsorten.xml. Idempotent: upserts fruits by osdb_number.

2. Import publications

DATABASE_URL=... python3 scripts/import_publications.py

Imports publications from 03-data/osws.xml (only <obj> elements with <osw>=1). For each publication: upserts the row, loads cover image, links fruits found by filesystem scan of 03-data/osdb/{pubId}/, and imports PDFs and fruit images. Idempotent: clears and re-inserts linked data on re-run.