This release is a pre-release and may not be stable for production use.
dbt-mysql
This plugin ports dbt functionality to MySQL 8.0.
This is an experimental plugin. Please read these docs carefully and use at your own risk. Issues and PRs welcome!
Untested
We have not tested it against older versions of MySQL or storage engines other than the default of InnoDB.
Compatiblity with other dbt packages (like dbt_utils) is also untested.
Installation
This plugin can be installed via pip:
# Install dbt-mysql from PyPi:
$ pip install dbt-mysql
dbt-mysql creates connections via an ODBC driver that requires pyodbc.
See https://github.com/mkleehammer/pyodbc/wiki/Install for more info about installing pyodbc.
Supported features
| Supported? | Feature |
|---|---|
| ✅ | Table materialization |
| ✅ | View materialization |
| ✅ | Incremental materialization |
| ✅ | Ephemeral materialization |
| ✅ | Seeds |
| ✅ | Sources |
| ✅ | Custom data tests |
| ✅ | Docs generate |
| ✅ | Snapshots |
Configuring your profile
A dbt profile can be configured to run against MySQL using the following configuration:
| Option | Description | Required? | Example |
|---|---|---|---|
| schema | Specify the schema (database) to build models into | Required | analytics |
| server | The server (hostname) to connect to | Required | yourorg.mysqlhost.com |
| username | The username to use to connect to the server | Required | dbt_admin |
| password | The password to use for authenticating to the server | Required | correct-horse-battery-staple |
| driver | ODBC DSN configured | Required | MySQL ODBC 8.0 ANSI Driver |
Example entry for profiles.yml:
your_profile_name:
target: dev
outputs:
dev:
type: mysql
server: localhost
schema: analytics
username: your_mysql_username
password: your_mysql_password
driver: MySQL ODBC 8.0 ANSI Driver
Notes
MySQL also has two-part relation names (similar to SQLite and Spark) whereas many database management systems have three-part relation names.
MySQL, dbt, and the ANSI-standard information_schema use different terminology for analagous concepts. Note that MySQL does not implement the top-level concept of the information_schema "catalog" (which dbt calls a "database").
This adapter handles the two-part relation names in MySQL similarly to the dbt-spark and dbt-sqlite adapters.
This is as a cross-walk between each concept:
| information_schema | MySQL | dbt |
|---|---|---|
| catalog | undefined / not implemented | database |
| schema | database | schema |
| table/view | table/view | relation |
| column | column | column |
Running Tests
- Modify
test/mysql.dbtspecwith yourserver,username, andpassword - Install the
pytest-dbt-adapterpackage - Run the test specs in this repository
pip install pytest-dbt-adapter
pytest test/mysql.dbtspec
Reporting bugs and contributing code
- Want to report a bug or request a feature? See the contributing guidelines, or open an issue.
Release files for dbt-mysql 0.18.0rc2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dbt-mysql-0.18.0rc2.tar.gz | 13.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dbt_mysql-0.18.0rc2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.6 kB
Release files / dbt-mysql-0.18.0rc2.tar.gz
| Download URL | dbt-mysql-0.18.0rc2.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
286cfdc941706387015538014881cf0dde598373ddbb4e5021f79f0d42ee690d
|
|
BLAKE2b-256 checksum How to use checksums |
65b4b9542943a833ae2ae6de9f135d21cc8f43735e6f7b3feccff3e46cd603ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.6.11
|
Release files / dbt_mysql-0.18.0rc2-py3-none-any.whl
| Download URL | dbt_mysql-0.18.0rc2-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2395be76056a3238cc389bed977b523cda6e355060678c460d491d9ca0db89a5
|
|
BLAKE2b-256 checksum How to use checksums |
e8be7f3249e8814de50e8366d8c26eb57899729746f4e9df9d2d976f94535207
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.6.11
|