
SQLMesh
CLI用 SQL 或 Python 编写数据转换模型的框架。提供类似 Terraform 的 plan / apply 流程、虚拟数据环境、单元测试和表差异比对,能在 10 多种 SQL 方言之间转译。Linux 基金会项目,可以替代 dbt。
SQLMesh is a project of the Linux Foundation.
SQLMesh is a next-generation data transformation framework designed to ship data quickly, efficiently, and without error. Data teams can run and deploy data transformations written in SQL or Python with visibility and control at any size.
It is more than just a dbt alternative.
Core Features
Get instant SQL impact and context of your changes, both in the CLI and in the SQLMesh VSCode Extension
Virtual Data Environments
- See a full diagram of how Virtual Data Environments work
- Watch this video to learn more
- Create isolated development environments without data warehouse costs
- Plan / Apply workflow like Terraform to understand potential impact of changes
- Easy to use CI/CD bot for true blue-green deployments
Efficiency and Testing
Running this command will generate a unit test file in the tests/ folder: test_stg_payments.yaml
Runs a live query to generate the expected output of the model
sqlmesh create_test tcloud_demo.stg_payments --query tcloud_demo.seed_raw_payments "select * from tcloud_demo.seed_raw_payments limit 5"
# run the unit test
sqlmesh test
MODEL (
name tcloud_demo.stg_payments,
cron '@daily',
grain payment_id,
audits (UNIQUE_VALUES(columns = (
payment_id
)), NOT_NULL(columns = (
payment_id
)))
);
SELECT
id AS payment_id,
order_id,
payment_method,
amount / 100 AS amount, /* `amount` is currently stored in cents, so we convert it to dollars */
'new_column' AS new_column, /* non-breaking change example */
FROM tcloud_demo.seed_raw_payments
test_stg_payments:
model: tcloud_demo.stg_payments
inputs:
tcloud_demo.seed_raw_payments:
- id: 66
order_id: 58
payment_method: coupon
amount: 1800
- id: 27
order_id: 24
payment_method: coupon
amount: 2600
- id: 30
order_id: 25
payment_method: coupon
amount: 1600
- id: 109
order_id: 95
payment_method: coupon
amount: 2400
- id: 3
order_id: 3
payment_method: coupon
amount: 100
outputs:
query:
- payment_id: 66
order_id: 58
payment_method: coupon
amount: 18.0
new_column: new_column
- payment_id: 27
order_id: 24
payment_method: coupon
amount: 26.0
new_column: new_column
- payment_id: 30
order_id: 25
payment_method: coupon
amount: 16.0
new_column: new_column
- payment_id: 109
order_id: 95
payment_method: coupon
amount: 24.0
new_column: new_column
- payment_id: 3
order_id: 3
payment_method: coupon
amount: 1.0
new_column: new_column
- Never build a table more than once
- Track what data’s been modified and run only the necessary transformations for incremental models
- Run unit tests for free and configure automated audits
- Run table diffs between prod and dev based on tables/views impacted by a change
Level Up Your SQL
Write SQL in any dialect and SQLMesh will transpile it to your target SQL dialect on the fly before sending it to the warehouse.
- Debug transformation errors before you run them in your warehouse in 10+ different SQL dialects
- Definitions using simply SQL (no need for redundant and confusing
Jinja+YAML) - See impact of changes before you run them in your warehouse with column-level lineage
For more information, check out the documentation.
Getting Started
Install SQLMesh through pypi by running:
mkdir sqlmesh-example
cd sqlmesh-example
python -m venv .venv
source .venv/bin/activate
pip install 'sqlmesh[lsp]' # install the sqlmesh package with extensions to work with VSCode
source .venv/bin/activate # reactivate the venv to ensure you're using the right installation
sqlmesh init # follow the prompts to get started (choose DuckDB)
Note: You may need to run
python3orpip3instead ofpythonorpip, depending on your python installation.
Windows Installation
mkdir sqlmesh-example
cd sqlmesh-example
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install 'sqlmesh[lsp]' # install the sqlmesh package with extensions to work with VSCode
.\.venv\Scripts\Activate.ps1 # reactivate the venv to ensure you're using the right installation
sqlmesh init # follow the prompts to get started (choose DuckDB)
Follow the quickstart guide to learn how to use SQLMesh. You already have a head start!
Follow the crash course to learn the core movesets and use the easy to reference cheat sheet.
Follow this example to learn how to use SQLMesh in a full walkthrough.
Join Our Community
Connect with us in the following ways:
- Join the Tobiko Slack Community to ask questions, or just to say hi!
- File an issue on our GitHub
- Send us an email at hello@tobikodata.com with your questions or feedback
- Read our blog
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines on how to contribute, including our DCO sign-off requirement.
Please review our Code of Conduct and Governance documents.
Read more on how to set up your development environment.
License
This project is licensed under the Apache License 2.0. Documentation is licensed under CC-BY-4.0.
相關資源

dbt Agent Skills
Skilldbt Labs 官方技能合集:编写与修改 dbt 模型、补单元测试与文档、搭建 MetricFlow 语义层、排查任务失败,以及 dbt 版本升级与跨平台迁移。多数技能需要已安装 dbt 并有现成项目。
dbt-labs/dbt-agent-skills737
DuckDB
CLI进程内分析型 SQL 数据库,命令行可直接用 SQL 查询 CSV、Parquet、JSON 文件,无需导入或启动服务,适合 agent 抽样与聚合大文件。官方维护。
duckdb/duckdb42.2k
dbt
CLI数仓建模与 ELT 转换的命令行框架:用 SQL 编写模型,自动处理依赖、数据测试与文档生成。v2 用 Rust 重写为单一二进制,dbt Labs 官方维护,需配置数据仓库连接。
dbt-labs/dbt14k
mycli
CLI带智能补全与语法高亮的 MySQL 终端客户端,兼容 MariaDB、TiDB 等;支持 --execute 与批处理模式,可按 CSV 或表格格式输出查询结果,便于 agent 直接执行 SQL。
dbcli/mycli12k
Datasette
CLI把 SQLite 数据库发布成可以浏览、可以查询的网页和 JSON API,支持 SQL 查询、元数据和插件扩展,也能用 datasette publish 部署到 Cloud Run 等平台。适合数据探索和数据新闻,需要 Python 3.10 及以上版本。
simonw/datasette11.5k
SQLFluff
CLI支持二十多种 SQL 方言的 linter 与格式化工具,可自动修复大部分问题,兼容 Jinja 模板与 dbt 项目(dbt 需装插件),适合在数仓代码评审和 CI 中使用。
sqlfluff/sqlfluff10k