Skip to main content

Config-driven CLI tool to migrate MSSQL databases to MySQL.

Project description

mssql2mysql

PyPI version License Python

A config-driven CLI tool to migrate Microsoft SQL Server databases to MySQL. Handles data, primary keys, and foreign keys with batch processing and progress tracking.

Features

  • Data migration — Copies all tables and rows with configurable batch size
  • Schema inference — Builds MySQL tables from MSSQL metadata with automatic type mapping
  • Primary keys — Migrates PK constraints from MSSQL to MySQL
  • Foreign keys — Migrates FK constraints with strict or smart mode
  • Progress tracking — Per-table progress bars and row counts
  • YAML config — Single config file for both source and target

Requirements

Installation

pip install mssql2mysql

Or from source:

git clone https://github.com/mananpatel08/mssql2mysql.git
cd mssql2mysql
pip install -e .

Quick Start

  1. Create a config file

    mssql2mysql --init
    

    This creates migration.yaml in the current directory.

  2. Edit the config with your MSSQL and MySQL connection details.

  3. Run the migration

    mssql2mysql --config migration.yaml
    

Configuration

Example migration.yaml (from --init):

mssql:
  server: localhost
  port: 1433
  database: your_database
  user: sa
  password: your_password

mysql:
  host: localhost
  database: your_database
  user: root
  password: your_password

mode: strict      # strict | smart
batch_size: 1000
Option Description
mssql.server MSSQL host
mssql.port MSSQL port (default 1433)
mssql.database Source database name
mssql.user / mssql.password MSSQL credentials
mysql.host MySQL host
mysql.database Target database name
mysql.user / mysql.password MySQL credentials
mode strict (default): stop on first FK error. smart: create indexes on referenced columns if needed, continue on FK errors.
batch_size Rows per insert batch (default 1000)

CLI Reference

Command Description
mssql2mysql --init Create a sample migration.yaml in the current directory.
mssql2mysql --config <file> Run migration using the given YAML config file.

Migration Modes

  • strict (default) — Stops the entire migration if any foreign key fails to be added. Use when you want a fully consistent schema.
  • smart — Before adding each FK, ensures the referenced column has an index (creates one if missing). On FK add failure, logs the error and continues with the rest. Use when some FKs may be invalid or you prefer best-effort migration.

Type Mapping

MSSQL types are mapped to MySQL as follows (among others):

MSSQL MySQL
varchar / nvarchar / char / nchar VARCHAR(n) or LONGTEXT (max)
decimal / numeric DECIMAL(p,s)
datetime / datetime2 DATETIME
date DATE
int INT
bigint BIGINT
bit TINYINT(1)
varbinary / binary / image BLOB / LONGBLOB

Unsupported types fall back to TEXT. Nullability is preserved.

How It Works

  1. Data — Connects to MSSQL and MySQL, reads table list and column metadata, creates MySQL tables with mapped types, then batch-inserts rows with progress output. Foreign key checks are disabled during data load.
  2. Primary keys — Reads PK definitions from MSSQL INFORMATION_SCHEMA, adds them in MySQL (skips if already present).
  3. Foreign keys — Reads FK definitions from MSSQL system tables, adds them in MySQL (in smart mode, creates indexes on referenced columns as needed).

Links

License

MIT © Manan Patel

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mssql2mysql-0.1.3.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mssql2mysql-0.1.3-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file mssql2mysql-0.1.3.tar.gz.

File metadata

  • Download URL: mssql2mysql-0.1.3.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mssql2mysql-0.1.3.tar.gz
Algorithm Hash digest
SHA256 b19e561cd25b65142c5762c292ef6c5a25718f5f7b11408c927c4c0772fd4578
MD5 a45203dbc4dbc6e3ed5693aab4e65e08
BLAKE2b-256 1e1d95954af8dae373bfcaccdbc38adc23d6f9e2f47d7b9a8406cc06c4bc66ae

See more details on using hashes here.

File details

Details for the file mssql2mysql-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: mssql2mysql-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mssql2mysql-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 335861a255810ae2de27e0cedf22e1147fe73a9599cc74fda6fd3c0234ffa4fd
MD5 1c989664a28da9a6387a52bb6f3903b2
BLAKE2b-256 117873842bbfed4af1321feabb463bdc8f7f2bcc29df62500ccfb76c1b821eeb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page