# dlt

**dlt**（data load tool，数据加载工具）是一个用于提取—加载数据管道的开源 Python 库：它从 REST API、SQL 数据库、云存储和 Python 数据结构等来源抽取数据，推断模式，规范化嵌套数据，并将结果加载到仓库、湖仓或本地数据库等目标端。<sup>[1](https://dlthub.com/docs/intro)</sup> 该项目由位于柏林和旧金山的 dltHub 公司开发，采用 Apache 2.0 许可证。<sup>[2](https://github.com/dlt-hub/dlt)</sup><sup> • </sup><sup>[3](https://dlthub.com/about)</sup> 不应将其与 [Databricks](https://www.edgepedia.org/zh/databricks) 的 Delta Live Tables 混淆，后者是一个范围不同的产品，Databricks 于 2026 年将其更名为 Lakeflow pipelines。<sup>[4](https://docs.databricks.com/aws/en/ldp/where-is-dlt)</sup>

| 关键事实 | 详情 |
|---|---|
| 是什么 | 用于数据摄取的开源 Python 库，Apache 2.0 许可，由 dltHub 维护<sup>[2](https://github.com/dlt-hub/dlt)</sup><sup> • </sup><sup>[5](https://dlthub.com/docs/hub/getting-started/oss-and-dlthub)</sup> |
| 核心循环 | 管道 `run` 执行三个阶段：提取、规范化、加载<sup>[6](https://dlthub.com/docs/reference/explainers/how-dlt-works)</sup> |
| 写入方式 | `replace`、`append` 和 `merge`（配合 `merge_key`/`primary_key`），按资源分别选择<sup>[7](https://dlthub.com/docs/general-usage/incremental-loading)</sup> |
| 模式处理 | 模式在规范化过程中从数据推断，并随来源变化自动演进<sup>[6](https://dlthub.com/docs/reference/explainers/how-dlt-works)</sup><sup> • </sup><sup>[8](https://dlthub.com/docs/general-usage/schema-evolution)</sup> |
| Python 支持 | Python 3.10 至 3.14；3.14 上部分可选附加功能为实验性<sup>[9](https://github.com/dlt-hub/dlt?ref=ssp.sh)</sup> |
| 成熟度 | 1.0.0 版于 2024 年 9 月 16 日发布；该公司报告当年增长 9 倍，生产环境中的开源客户超过 1,000 家<sup>[10](https://dlthub.com/blog/dlt-v1)</sup> |
| 代码仓库 | 约 6,000 个 GitHub 星标，632 个复刻，4,520 次提交<sup>[2](https://github.com/dlt-hub/dlt)</sup> |

## 管道的工作方式

主要构建单元是管道。调用其 `run` 方法会执行三个独立阶段。<sup>[6](https://dlthub.com/docs/reference/explainers/how-dlt-works)</sup>

**提取。** dlt 将数据从来源完整提取到本地硬盘，存入一个加载包，该加载包获得唯一 ID，并按接收原样存储原始数据。用户可以提供模式提示来定义列类型，或添加主键和唯一索引；限制每次运行的项目数量；使用增量游标字段；并行化；并应用过滤器或映射来混淆或删除个人数据。<sup>[6](https://dlthub.com/docs/reference/explainers/how-dlt-works)</sup>

**规范化。** 规范化器检查数据，计算出与目标端兼容的模式，并将数据重构为目标端的格式。嵌套字典被展平，嵌套列表被解包为子表；例如，`items` 表内的 `nested` 列表会变成名为 `items__nested` 的子表。如果某个值的类型与之前运行计算出的模式不匹配，dlt 会创建一个变体列，模式会自动演进以容纳新列或新表。<sup>[6](https://dlthub.com/docs/reference/explainers/how-dlt-works)</sup> 用户可以限制允许的嵌套层级，并应用模式契约，规定模式可以如何演进以及如何处理不符合约定的行。<sup>[6](https://dlthub.com/docs/reference/explainers/how-dlt-works)</sup>

**加载。** dlt 在目标端执行所需的模式迁移，并以称为加载作业的块为单位加载数据，从而可以并行处理大批量加载。如果与目标端的连接失败，重新运行管道是安全的：dlt 会从当前加载包继续加载所有作业。dlt 还会创建特殊的内部表，存储模式、加载包信息和状态，增量管道用这些表从之前的运行恢复状态，即使是在另一台机器上。<sup>[6](https://dlthub.com/docs/reference/explainers/how-dlt-works)</sup>

每个阶段也可以用 `pipeline.extract`、`pipeline.normalize` 和 `pipeline.load` 单独运行；规范化需要已完成提取的数据，加载需要已完成规范化的数据。<sup>[6](https://dlthub.com/docs/reference/explainers/how-dlt-works)</sup>

## 来源与目标端

来源在 Python 中声明。声明式 REST API 来源接收基础 URL、认证、分页器类型和资源名称，并处理请求、分页、模式推断和类型标注。<sup>[1](https://dlthub.com/docs/intro)</sup> SQL 数据库来源从 [PostgreSQL](https://www.edgepedia.org/zh/postgresql)、MySQL、SQLite 和 Oracle 等数据库读取，文件系统来源从 AWS S3、Google Cloud Storage、Google Drive、Azure 或本地文件读取。普通 Python 生成器和数据结构也可以直接使用。<sup>[1](https://dlthub.com/docs/intro)</sup>

目标端包括 [Snowflake](https://www.edgepedia.org/zh/snowflake)、BigQuery、Databricks、Redshift、Postgres、DuckDB、ClickHouse、Athena、MotherDuck、文件系统湖和向量存储，另有用于反向 ETL 的自定义目标端接口。<sup>[11](https://dlthub.com/product/dlt)</sup><sup> • </sup><sup>[1](https://dlthub.com/docs/intro)</sup> 对于某些目标端，可以使用存储桶提供商上的远程暂存数据集，dlt 支持包括 Delta 和 Iceberg 在内的开放表格式。<sup>[6](https://dlthub.com/docs/reference/explainers/how-dlt-works)</sup> 一种常见工作流是在本地针对 DuckDB 构建和测试，然后切换目标端进行部署。<sup>[6](https://dlthub.com/docs/reference/explainers/how-dlt-works)</sup>

## 写入方式与增量加载

dlt 提供三种按资源设置的写入方式。`replace` 用本次运行来源产出的数据替换目标数据集；`append` 添加新数据；`merge` 按配置的 `merge_key` 合并，或按 `primary_key` 去重并 upsert。<sup>[7](https://dlthub.com/docs/general-usage/incremental-loading)</sup> 文档围绕数据来阐述选择：无状态数据（如页面浏览记录）可以直接追加，而有状态数据（如用户画像）需要合并、全量替换，或在必须保留变更历史时使用缓慢变化维度（Type-2）。<sup>[7](https://dlthub.com/docs/general-usage/incremental-loading)</sup>

增量加载只加载新增或变更的记录。dlt 提供四种方法：合并策略（`delete-insert`、`scd2`、`upsert`、`insert-only` 和 `cdc`）、基于时间戳或 ID 字段的游标跟踪、在特定时间范围内刷新数据的滞后或归因窗口，以及自定义状态管理。<sup>[7](https://dlthub.com/docs/general-usage/incremental-loading)</sup>

**刷新。** 通过 `refresh` 选项可以对合并和追加资源进行全量或部分刷新，可在代码中或通过环境变量设置：`drop_data` 截断表并重置增量状态，但不改变模式；`drop_resources` 还会从模式中删除表并清除存储的模式历史；`drop_sources` 对整个来源执行上述两项操作。截断在加载步骤开始时发生，因此提取或规范化失败不会影响目标端数据。<sup>[7](https://dlthub.com/docs/general-usage/incremental-loading)</sup>

## 模式推断与演进

首次运行会扫描数据并生成模式，展平字典并将嵌套列表解包为子表。<sup>[8](https://dlthub.com/docs/general-usage/schema-evolution)</sup> 随着来源变化，dlt 会自动处理差异：新增列会被添加，删除的列只是停止接收数据，重命名的列停止以旧名称加载并创建新列，类型变更会产生变体列（例如，当整数列开始承载字符串时，产生 `inventory_nr__v_text`）。<sup>[8](https://dlthub.com/docs/general-usage/schema-evolution)</sup>

默认的关系规范化器将嵌套数据展平为关系表，并在兼容类型之间强制转换值；另一个规范化器 `relational_no_coercion` 从不强制转换，对每种类型不匹配都产生变体列。用户可以接入自定义规范化器，例如生成类似 parquet 的结构而不是嵌套表。<sup>[12](https://dlthub.com/docs/general-usage/schema)</sup> 每个模式都带有一个基于内容的 `version_hash`，用于检测手动编辑并检查目标数据库模式是否同步，以及一个人类可读的数字版本号，每次保存更新时递增。<sup>[12](https://dlthub.com/docs/general-usage/schema)</sup> 模式契约和数据契约（模式如 `evolve`、`freeze`、`discard_rows` 和 `discard_columns`）规定了写入目标端的模式可以如何变化。<sup>[8](https://dlthub.com/docs/general-usage/schema-evolution)</sup>

## 生态系统与采用情况

dlt 以普通 Python 包形式分发，凡能运行 Python 的环境都能运行，包括 notebook、无服务器函数、Airflow 等编排器和 AI 编码代理；文档指出该库和文档是为代理原生而构建的，提供了超过 8,000 个来源的脚手架。<sup>[1](https://dlthub.com/docs/intro)</sup> 1.0.0 版于 2024 年 9 月发布，将数据库同步、文件系统加载、REST API 工具包和 SQLAlchemy 目标端集成到核心库中。<sup>[10](https://dlthub.com/blog/dlt-v1)</sup> 代码仓库于 2022 年 1 月开放，该公司报告每月 PyPI 下载量超过 600 万次，贡献者 213 人。<sup>[13](https://www.faun.dev/toolbox/dlt/review/)</sup>

在 dltHub 发布的一项使用 TPC-H 数据集进行 SQL 到 SQL 复制的基准测试中，在 8 核、16 GB 的 Google Cloud 虚拟机上处理约 6.42 GB 和 24,604,860 行数据，使用 ConnectorX 后端的 dlt 在 3.21 分钟内完成加载，而 Sling 为 13.98 分钟，Airbyte 为 19.55 分钟，[Meltano](https://www.edgepedia.org/zh/meltano) 为 2 小时 42 分钟。<sup>[14](https://dlthub.com/blog/self-hosted-tools-benchmarking)</sup>

**与相关工具的比较。** Airbyte 是一个带有 UI、连接器目录和服务器的平台，Meltano 从 CLI 编排现有的 Singer tap 和 target，与此不同，dlt 是一个直接编写代码来使用的 Python 库，提供更多代码和更多控制。<sup>[15](https://hysenlabs.com/projects/meltano-meltano)</sup> 2026 年的一项评测在 11 项 ELT 标准上给 dlt 打了 77/100，Meltano 为 71/100，差距最大的是模式漂移处理。<sup>[16](https://www.faun.dev/toolbox/dlt-vs-meltano/)</sup> 开源库免费，而 dltHub 销售一个商业平台，提供托管运行时来部署、监控和扩展 dlt 管道，并包含数据质量检查和转换。<sup>[5](https://dlthub.com/docs/hub/getting-started/oss-and-dlthub)</sup>

## References

1. [Introduction, dlt Docs](https://dlthub.com/docs/intro)
2. [dlt-hub/dlt GitHub repository](https://github.com/dlt-hub/dlt)
3. [About dltHub](https://dlthub.com/about)
4. [What happened to Delta Live Tables (DLT)? Databricks on AWS](https://docs.databricks.com/aws/en/ldp/where-is-dlt)
5. [dlt and dltHub, dltHub Docs](https://dlthub.com/docs/hub/getting-started/oss-and-dlthub)
6. [How dlt works, dlt Docs](https://dlthub.com/docs/reference/explainers/how-dlt-works)
7. [Incremental loading, dlt Docs](https://dlthub.com/docs/general-usage/incremental-loading)
8. [Schema evolution, dlt Docs](https://dlthub.com/docs/general-usage/schema-evolution)
9. [dlt-hub/dlt README (ssp.sh referrer mirror)](https://github.com/dlt-hub/dlt?ref=ssp.sh)
10. [Introducing dlt 1.0.0, dltHub blog](https://dlthub.com/blog/dlt-v1)
11. [dlt: the data loading library for Python, dltHub](https://dlthub.com/product/dlt)
12. [Schema, dlt Docs](https://dlthub.com/docs/general-usage/schema)
13. [dlt Review: Score, Pros and Cons, FAUN.dev](https://www.faun.dev/toolbox/dlt/review/)
14. [Self hosted tools Benchmarking, dltHub blog](https://dlthub.com/blog/self-hosted-tools-benchmarking)
15. [Meltano tutorial: install, taps and Singer ELT, Hysen Labs](https://hysenlabs.com/projects/meltano-meltano)
16. [dlt vs Meltano: Data Integration (ELT) Comparison (2026), FAUN.dev](https://www.faun.dev/toolbox/dlt-vs-meltano/)

---
*Initially written Oct 26, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Databases and data systems › Data mining, warehousing, and big data › Big data platforms and frameworks

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/dlt

English original: https://www.edgepedia.org/dlt
