Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Recursive Fetch

Pulls data from an Infor CSD FetchWhere API endpoint into a CSV file, automatically paging through results using the API's RestartRowID mechanism until the full result set has been retrieved.

How it works

  1. Authenticates against Infor ION using an .ionapi credentials file (OAuth2 password grant with the file's SAAK/SASK service account credentials).
  2. Calls SX/rest/serviceinterface/proxy/FetchWhere with the company, operator, table, and where-clause settings from config.ini.
  3. Each response includes a RestartRowID. The script feeds that value back into the next request and keeps calling until a page comes back empty or the restart ID stops advancing.
  4. All rows returned across every page are combined and written to a single CSV, with column headers taken from the union of fields seen across all rows (some tables return different fields per row).

The record list in the API response is wrapped under a key whose name depends on the table being queried (e.g. ttbledie for the edie table), so the script doesn't assume a fixed key — it locates the list-valued field in the response automatically.

Setup

py -m venv venv
venv\Scripts\activate
pip install -r requirements.txt

Place your .ionapi credentials file in config/ and point to it from config.ini.

Configuration

Edit config/config.ini:

[ionapi]
; Path to the .ionapi credentials file, relative to this config file or absolute.
file = NSACOM_DEM.ionapi

[fetchwhere]
; These map directly to the FetchWhere request payload.
CompanyNumber = 1000
Operator = sys
TableName = edie
WhereClause =
BatchSize = 500

[output]
; Directory where the resulting CSV file will be written.
directory = ../output
  • Operator must be a valid operator/user ID on file in the ERP system (e.g. sys), not a comparison operator like EQ.
  • WhereClause is passed through as-is, e.g. cono = 1 and errty = 'e'. Leave blank to fetch all rows.

Usage

venv\Scripts\python.exe fetch_where.py --config config/config.ini

Output is written to the configured output directory as:

<tenant>_<TableName>_<YYYYmmdd_HHMMSS>.csv

where <tenant> is the ti value from the .ionapi file.

Notes

  • .ionapi files contain live credentials and are excluded from git via .gitignore — don't commit them.
  • Large tables can return tens of thousands of rows across hundreds of pages; there's no built-in row limit, so scope the WhereClause if you only need a subset.

About

FetchWhere recursively to allow pulling more records than batch size

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages