{
 "schema_version": 1,
 "generated": "2026-11-01",
 "id": "dlt-hub-dlt--load-incrementally-with-dlt-decorators",
 "repo": "dlt-hub/dlt",
 "repo_url": "https://github.com/dlt-hub/dlt",
 "repo_slug": "dlt-hub-dlt",
 "title": "Load only new rows and upsert on a key",
 "page_title": "How to load only new rows and upsert on a key with DLT",
 "summary": "Use the resource decorator to declare primary key, merge write disposition, column hints and a schema contract.",
 "who": "An engineer running the same pipeline every hour.",
 "problem": "Reloading everything each run is slow and duplicates rows.",
 "outcome": "A pipeline that upserts on your key and only pulls changed rows.",
 "steps": [
  "Install the library with `pip install dlt`",
  "Decorate your generator with @DLT.resource and set primary_key and write_disposition to merge for upserts",
  "Add `updated_at=dlt.sources.incremental(\"updated_at\")` as an argument and fetch only rows after updated_at.last_value",
  "Guard the shape with schema_contract, choosing evolve, freeze or discard per tables, columns and data_type"
 ],
 "agent_prompt": "With dlt-hub/dlt, convert <my full reload script> into an incremental merge resource keyed on id, and freeze the columns so unexpected fields are rejected.",
 "agents": [
  "claude-code",
  "codex",
  "cursor",
  "gemini-cli"
 ],
 "difficulty": "Intermediate",
 "time": "1 hour",
 "basis": "readme",
 "caveat": "Freeze rejects the record while discard drops the offending row or column, so pick deliberately.",
 "category": "Data and analytics",
 "tags": [
  "Data and analytics"
 ],
 "lang": "",
 "requirements": [
  "Python 3.10 through 3.14, with 3.14 support described as experimental",
  "`pip install dlt` plus the extras for your sources and destinations",
  "Credentials for your destination in secrets.toml or environment variables"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.9,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/dlt-hub-dlt/load-incrementally-with-dlt-decorators/",
 "md": "https://dedupedai.com/use-cases/dlt-hub-dlt/load-incrementally-with-dlt-decorators/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/dlt-hub-dlt--load-incrementally-with-dlt-decorators.json",
 "api_version": "v1"
}
