data-engineering
Technical notes on web development, DevOps, and AI integration.
8 articles
- 23:31backend
When the Source Shrinks: Reconcile in the Importer
63 rows in, 65 rows in the database: the importer itself deletes entities the source no longer lists.
TL;DR: The importer treats deletion as part of its contract: any category entity whose attributes.no is missing from the source JSON gets removed in the same run. Idempotency keys use source numbers instead of slugs to prevent resurrection, and ON DELETE CASCADE cleans up media. Dry-run plus result counters verified it: 65 seeded, 63 kept, 2 deleted, then zero changes on rerun.
#data-engineering#importer#database - 22:34backend
Swapped Coordinates and the Honest Import
22 heritage records, one swapped column pair, and six drafts: what an honest data import looks like.
TL;DR: While importing a heritage site spreadsheet, the author found latitude and longitude columns swapped, plus typo'd prefixes, duplicate coordinates, and one missing record. The fixed importer parses with column swap, preserves raw DMS strings, and routes suspect rows to draft with a geo_review flag instead of publishing. Result: 16 records published, 6 drafted, and reruns are fully idempotent.
#data-engineering#importer#geospasial - 20:10backend
Three Mapper Gaps Only Real Data Reveals
Green fixtures prove nothing: a nested object, camelCase keys, and full datetimes only surfaced once 5,330 real rows hit the pipeline.
TL;DR: A 5,330-row blacklist dump mapped error-free yet left company and date columns empty, because real rows broke three assumptions: nested provider objects, camelCase keys, and full RFC 3339 datetimes. Fixes layered a fallback resolver, one shared field registry, and regex date extraction. All 5,330 rows then ingested cleanly, confirming the lesson: start from row zero of real data.
#python#data-engineering#schema - 18:58backend
The event_date Column That Was Always NULL
Indonesian month-name dates kept an event_date column empty. The stdlib locale is not the answer; an explicit month table is.
TL;DR: Date-range queries kept returning empty because Indonesian date strings silently failed ISO parsing. Locale-based fixes proved fragile, so the team chose a simple 13-entry month table with one shared field list in the domain layer. Fifty-three tests plus a live remap of 20 cases filled every date with zero errors.
#python#locale#data-engineering - 15:19backend
Recovery-Only Rebuild: Lessons from a Corrupted Ledger
A rebuild turned 20 healthy ledger rows into 77 UNKNOWN. The fix: a recovery-only contract that fills gaps and never rewrites healthy rows.
TL;DR: A rebuild tool corrupted a court-rulings ledger, inflating twenty healthy rows to seventy-seven, mostly tagged UNKNOWN. The cause was structural: per-tab raw files re-parsed as new records, proving raw-is-truth doesn't make re-parses safe. The redesign makes rebuild recovery-only: healthy rows stay verbatim, only missing cases are appended, sub-tab files are skipped, and any UNKNOWN aborts all writes.
#python#data-engineering#sqlite - 12:19backend
When Deep Links Rotate, the Search Box Is the Address
Pagination URLs carry rotating session tokens that die within the hour. Drive the app's own search form instead, then flatten parsed values before comparing.
TL;DR: Apps that mint session-bound URLs make deep links unreliable, so drive the search form instead: type the exact document number, verify the detail page, and log the query rather than the link. Normalize parser output by flattening lists and lowercasing strings before status comparisons. Flag mismatches for human review instead of stopping the run.
#scraping#python#data-engineering - 11:14backend
Through One Door: A Retry-Safe Harvest Ingest Contract
A scraping workspace kept apart from the app, and a replayable single-door API delivery: resumable queue, stable dedupe key, ship log.
TL;DR: A mid-run interruption exposed the risk of writing scrape results straight into the app database, so this commit isolates all scraping tools and stores per-page, per-subtab queue rows with status and attempt logs on disk. Resuming is then deterministic. Shipping happens separately through one ingest endpoint, using stable deduplication keys and exponential backoff so idempotent retries make replays safe.
#scraping#idempotency#data-engineering - 10:30backend
The Raw-First Pattern for Gated Data Harvests
Why gated data harvests save verbatim raw text before parsing: an idempotent ledger, a resumable cursor, and retroactive rebuilds.
TL;DR: When scraping captcha-gated, session-locked court portals, save the verbatim rendered text first and parse later from local files. Resumable cursors and idempotent upserts keep crashes from corrupting data. This bronze-layer approach means parser fixes apply retroactively without ever hitting the fragile site again.
#scraping#idempotency#audit-trail