Docs/Engines/MySQL

MySQL

MySQL commits each DDL statement as it runs, so a migration that fails half-way leaves the statements before it applied. Keep migrations small and rehearse the release before applying it.

type
mysql
Driver
pymysql
DDL
Auto-commits
Identifiers
Backticks, folded to lowercase

Install

pip install "dblift[mysql]"

Connection URL

mysql+pymysql://user:password@localhost:3306/app

A plain mysql:// URL is accepted and normalised to mysql+pymysql. Without a URL, DBLift builds one from host, port, database, username and password.

dblift.yaml

database:
  type: mysql
  url: "mysql+pymysql://db.internal:3306/app"
  ssl_enabled: true
  connection_timeout: 30
  session_variables:
    time_zone: "+00:00"

Engine settings

KeyDefaultEffect
ssl_enabledfalseAdds ssl=true to the connection URL.
connection_timeout30Sent to the driver as connect_timeout.
session_variables{}Rendered into one SET SESSION statement and passed as init_command, so every connection starts the same way.
options{}Merged into the URL query string after extra_params, so options wins on a clash.

Behaviour notes

DDL auto-commits.

A failed migration leaves the statements that already ran in place. The history row is marked failed; clear it with repair once the database is back to a known state.

Identifiers are quoted with backticks.

DBLift folds unquoted names to lowercase. Quote with backticks to keep mixed case.

A self-referencing UPDATE needs a derived table.

MySQL rejects UPDATE t … WHERE id IN (SELECT id FROM t) with error 1093, so DBLift wraps the subquery for you.

Catalog reads end in a rollback.

Introspection closes its own transaction, so reading metadata never leaves a lock behind.

The session is not put in autocommit.

DBLift opens and commits each transaction itself.

Generated SQL targets 8.0.19 or later.

A captured server older than 8.0.19 is warned about. Nothing is rendered differently for it.