Skip to main content

MySQL Reference

Authentication options and data type handling for MySQL connections.

Authentication

VariableExampleDescription
DATACONTRACT_MYSQL_USERNAMErootUsername
DATACONTRACT_MYSQL_PASSWORDmysecretpasswordPassword

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 typelogicalType
VARCHAR, CHAR, TEXTstring (maxLength for varchar/char)
INT, INTEGER, BIGINT, SMALLINTinteger
NUMERIC, DECIMAL, FLOAT, DOUBLEnumber
BOOLEANboolean
DATEdate
TIMEtime
DATETIME, TIMESTAMPtimestamp
BLOB, BINARY, VARBINARYstring (format binary)
JSONobject
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:

logicalTypeMySQL type
stringvarchar(255)
integerint
numberdecimal
booleanboolean
datedate
timestamptimestamp
timetime
objectjson
arrayjson