{"id":18408362,"url":"https://github.com/pingcap/dbt-tidb","last_synced_at":"2025-08-05T04:18:57.102Z","repository":{"id":47615999,"uuid":"476565626","full_name":"pingcap/dbt-tidb","owner":"pingcap","description":"A dbt adapter for TiDB","archived":false,"fork":false,"pushed_at":"2023-12-14T05:45:23.000Z","size":230,"stargazers_count":14,"open_issues_count":9,"forks_count":10,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-12-18T16:35:15.433Z","etag":null,"topics":["dataanalysis","database","dbt","mysql","python","sql","tidb"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pingcap.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-01T03:51:20.000Z","updated_at":"2024-04-18T03:17:45.000Z","dependencies_parsed_at":"2024-11-06T03:20:31.066Z","dependency_job_id":"4bf07037-ce1e-401d-8860-0d29ce7dd5a7","html_url":"https://github.com/pingcap/dbt-tidb","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingcap%2Fdbt-tidb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingcap%2Fdbt-tidb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingcap%2Fdbt-tidb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingcap%2Fdbt-tidb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pingcap","download_url":"https://codeload.github.com/pingcap/dbt-tidb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247626461,"owners_count":20969307,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dataanalysis","database","dbt","mysql","python","sql","tidb"],"created_at":"2024-11-06T03:18:45.108Z","updated_at":"2025-04-07T09:32:52.684Z","avatar_url":"https://github.com/pingcap.png","language":"Python","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/pingcap/tidb/blob/21847fe58b51807696debf0f7650af948f2aa3e2/docs/logo_with_text.png\" alt=\"TiDB logo\" /\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/dbt-labs/dbt/ec7dee39f793aa4f7dd3dae37282cc87664813e4/etc/dbt-logo-full.svg\" alt=\"dbt logo\" width=\"250\"/\u003e\n\u003c/p\u003e\n\n# dbt-tidb\n\n![PyPI](https://img.shields.io/pypi/v/dbt-tidb)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dbt-tidb)\n![PyPI - Downloads](https://img.shields.io/pypi/dw/dbt-tidb)\n[![Integration Test](https://github.com/pingcap/dbt-tidb/actions/workflows/main.yml/badge.svg)](https://github.com/pingcap/dbt-tidb/actions/workflows/main.yml)\n\nThe `dbt-tidb` package contains all of the code enabling [dbt](https://getdbt.com) to work with \n[TiDB](https://en.pingcap.com/tidb/).\n\nThis repository is partly based on [dbt-mysql](https://github.com/dbeatty10/dbt-mysql).\nThanks to them for their excellent work.\n\n## Table of Contents\n * [Installation](#installation)\n * [Supported features](#supported-features)\n * [Supported functions](#supported-functions)\n * [Profile Configuration](#profile-configuration)\n * [Database User Privileges](#database-user-privileges)\n * [Running Tests](#running-tests)\n * [Example](#example)\n * [Contributing](#contributing)\n\n## Installation\nCompile by source code.\n\n```bash\n$ git clone https://github.com/pingcap/dbt-tidb.git\n$ cd dbt-tidb\n$ pip install .\n```\nAlso, you can get it from pypi.\n\n```bash\n$ pip install dbt-tidb\n```\n## Supported features\n\n|    TiDB 4.X    | TiDB 5.0 ~ 5.2 |   TiDB \u003e= 5.3    |           Feature           |\n|:--------------:|:--------------:|:----------------:|:---------------------------:|\n|       ✅        |       ✅       |        ✅        |    Table materialization    |\n|       ✅        |       ✅       |        ✅        |    View materialization     |\n|       ❌        |       ❌       |        ✅        | Incremental materialization |\n|       ❌        |       ✅       |        ✅        |  Ephemeral materialization  |\n|       ✅        |       ✅       |        ✅        |            Seeds            |\n|       ✅        |       ✅       |        ✅        |           Sources           |\n|       ✅        |       ✅       |        ✅        |      Custom data tests      |\n|       ✅        |       ✅       |        ✅        |        Docs generate        |\n|       ❌        |       ❌       |        ✅        |          Snapshots          |\n|       ✅        |       ✅       |        ✅        |      Connection retry       |\n|       ✅        |       ✅       |        ✅        |            Grant            |\n\nNote: \n\n* TiDB 4.0 ~ 5.0 does not support [CTE](https://docs.pingcap.com/tidb/dev/sql-statement-with), \n  you should avoid using `WITH` in your SQL code.\n* TiDB 4.0 ~ 5.2 does not support creating a [temporary table or view](https://docs.pingcap.com/tidb/v5.2/sql-statement-create-table#:~:text=sec\\)-,MySQL%20compatibility,-TiDB%20does%20not).\n* TiDB 4.X does not support using SQL func in `CREATE VIEW`, avoid it in your SQL code. \n  You can find more detail [here](https://github.com/pingcap/tidb/pull/27252).\n\n## Supported functions\n\ncross-db macros are moved from dbt-utils into dbt-core, so you can use the following functions directly, see [dbt-util](https://github.com/dbt-labs/dbt-utils) on how to use them.\n- bool_or\n- cast_bool_to_text\n- dateadd\n- datediff\n- date_trunc\n- hash\n- safe_cast\n- split_part\n- last_day\n- cast_bool_to_text\n- concat\n- escape_single_quotes\n- except\n- intersect\n- length\n- position\n- replace\n- right\n- listagg (not support yet)\n\n\u003e pay attention that datediff is a little different from dbt-util that it will round down rather than round up.\n\n## Profile Configuration\n\nTiDB targets should be set up using the following configuration in your `profiles.yml` file.\n\n**Example entry for profiles.yml:**\n\n```\nyour_profile_name:\n  target: dev\n  outputs:\n    dev:\n      type: tidb\n      server: 127.0.0.1\n      port: 4000\n      schema: database_name\n      username: tidb_username\n      password: tidb_password\n      retries: 2\n```\n\n| Option           | Description                                           | Required? | Example                        |\n|------------------|-------------------------------------------------------|-----------|--------------------------------|\n| type             | The specific adapter to use                           | Required  | `tidb`                         |\n| server           | The server (hostname) to connect to                   | Required  | `yourorg.tidb.com`             |\n| port             | The port to use                                       | Required  | `4000`                         |\n| schema           | Specify the schema (database) to build models into    | Required  | `analytics`                    |\n| username         | The username to use to connect to the server          | Required  | `dbt_admin`                    |\n| password         | The password to use for authenticating to the server  | Required  | `correct-horse-battery-staple` |\n| retries          | The retry times for connection to TiDB (1 in default) | Optional  | `2`                            |\n\n## Database User Privileges\n\nYour database user would be able to have some abilities to read or write, such as `SELECT`, `CREATE`, and so on.\nYou can find some help [here](https://docs.pingcap.com/tidb/v4.0/privilege-management) with TiDB privileges management.\n\n| Required Privilege     |\n|------------------------|\n| SELECT                 |\n| CREATE                 |\n| CREATE TEMPORARY TABLE |\n| CREATE VIEW            |\n| INSERT                 |\n| DROP                   |\n| SHOW DATABASE          |\n| SHOW VIEW              |\n| SUPER                  |\n\n## Running Tests\n\nSee [tests/README.md](tests/README.md) for details on running the integration tests.\n\n## Example\n\nClick [here](https://github.com/pingcap/dbt-tidb/wiki/Primer-Tutorial-%7C-How-to-use-dbt-with-TiDB) to see a simple example about using dbt with dbt-tidb.\n\n## Contributing\n\nWelcome to contribute for dbt-tidb. See [Contributing Guide](CONTRIBUTING.md) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingcap%2Fdbt-tidb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpingcap%2Fdbt-tidb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingcap%2Fdbt-tidb/lists"}