Skip to content

HDXDSYS-3010 - Add datastore query and dump helpers to Resource - #115

Merged
mcarans merged 1 commit into
mainfrom
datastore_queries
Oct 13, 2026
Merged

mcarans merged 1 commit into
mainfrom
datastore_queries

Conversation

@mcarans

@mcarans mcarans commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Adds read helpers to Resource alongside the existing create_datastore/update_datastore/delete_datastore:

Method Wraps
search_datastore(filters, q, fields, sort, distinct, limit, offset, include_total, **kwargs) datastore_search, returns the result dict
get_datastore_records(..., page_size=10000) datastore_search, generator paging through all matching rows
get_datastore_fields() datastore_search with limit=0, excludes _id
Resource.search_datastore_sql(sql, configuration=None) datastore_search_sql, returns records
get_datastore_dump_url(file_format="csv") /datastore/dump/{id} (csv, tsv, json, xml)
download_datastore(folder, filename, file_format, retriever) Downloads the dump via get_ckan_ready_session, like download()

Failures raise HDXError (via _write_to_hdx). A new "Datastore" section in documentation/index.md covers these and the existing datastore methods.

hdx-scraper-jenkinsbuilds and hdx-scraper-jenkinsstats build dump URLs by hand and could use download_datastore once released.

Testing

  • Unit tests with mocked CKAN for all new methods.
  • Prod, read-only, public resource aid-worker-security-data-global (5905 rows): all helpers worked, including full paging, SQL and dumps in all four formats.
  • Stage, throwaway private dataset (created then deleted): all API helpers worked. Dumps return 401 on stage because nginx puts /datastore/dump/ behind basic auth (WWW-Authenticate: Basic realm="restricted").
  • HDX prod requires an API key for all datastore actions and dumps, including on public resources.

Add search_datastore, get_datastore_records, get_datastore_fields,
search_datastore_sql, get_datastore_dump_url and download_datastore.
Document datastore methods.
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Test Results

169 tests  +2   169 ✅ +2   1m 18s ⏱️ +18s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 2ed2b6f. ± Comparison against base commit fe6bfa4.

♻️ This comment has been updated with latest results.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 97.187% (+0.05%) from 97.135% — datastore_queries into main

@mcarans
mcarans merged commit 9f26fee into main Oct 13, 2026
6 of 7 checks passed
@mcarans mcarans changed the title Add datastore query and dump helpers to Resource HDXDSYS-3010 - Add datastore query and dump helpers to Resource Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants