MySQL Reference
Authentication options and data type handling for MySQL connections.
Authentication
| Variable | Example | Description |
|---|---|---|
DATACONTRACT_MYSQL_USERNAME | root | Username |
DATACONTRACT_MYSQL_PASSWORD | mysecretpassword | Password |
host, port (default 3306), and database come from the contract's servers block.
Data types
Importing
datacontract import sql --dialect mysql maps DDL types as follows; the normalized SQL type is kept as physicalType.
| MySQL type | logicalType |
|---|---|
VARCHAR, CHAR, TEXT | string (maxLength for varchar/char) |
INT, INTEGER, BIGINT, SMALLINT | integer |
NUMERIC, DECIMAL, FLOAT, DOUBLE | number |
BOOLEAN | boolean |
DATE | date |
TIME | time |
DATETIME, TIMESTAMP | timestamp |
BLOB, BINARY, VARBINARY | string (format binary) |
JSON | object |
ENUM(...), YEAR, TINYINT(1), INT UNSIGNED | (unset) — physicalType is still written |
Testing
MySQL is reached through DuckDB's MySQL scanner and does not support native type introspection — the declared physicalType is not compared against the catalog. Instead, the logicalType is checked by category (Check that field x has type y), with integer and number treated as compatible.
Logical type mapping
When no physicalType is declared, the CLI derives the native type from the logicalType — for example in datacontract export sql and the dbt exports. This table is generated from the converter in the CLI's code:
logicalType | MySQL type |
|---|---|
string | varchar(255) |
integer | int |
number | decimal |
boolean | boolean |
date | date |
timestamp | timestamp |
time | time |
object | json |
array | json |