ecomdev / mysql-to-jsonl
Export/Import JSONL files as data for MySQL tables
Requires
- php: ~8.2
- ext-pdo: *
- amphp/amp: ~3.0
- amphp/parallel: ~v2.3.1
- justinrainbow/json-schema: ^6.0
- revolt/event-loop: ~1.0
- symfony/console: ~7.2
Requires (Dev)
- brianium/paratest: ^7.7
- ecomdev/testcontainers-magento-data: ~1.2
- phpunit/phpunit: ^11.5
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2025-01-27 17:41:00 UTC
README
Purpose:
The mysql2jsonl
tool provides an efficient way to export data from a MySQL database to JSONL (JSON Lines) files and to import data back into a database from these files.
It is highly configurable and optimized for performance with concurrency and batching in mind!
Key Features:
-
Export and Import Commands
mysql2jsonl export
: Exports MySQL database table data into JSONL files.mysql2jsonl import
: Imports JSONL files back into the MySQL database tables.
-
Complex rules for excluding/including tables into the export
-
No compromise on performance!
-
JSONSchema for configuration validation, no more guessing when editing config file.
Configuration file example
If you want to export / import data from mysql server reachable via db
hostname
and exclude tables that match indexation patterns, you configuration file will look like this:
{ "$schema": "https://raw.githubusercontent.com/EcomDev/mysql-to-jsonl/main/schema.json", "config": { "connection": { "host": "db", "database": "magento", "user": "magento", "password": "magento" }, "excludeTables": [ { "endsWith": "_cl" }, { "contains": "_tmp_" }, { "contains": "_index_" }, { "endsWith": "_index" }, { "endsWith": "_replica" }, { "regexp": "/^inventory_stock_\\d+$/" } ], "concurrency": 12 } }
Notice the $schema
in as the first element? Specifying it like this in your config files
allows your favorite IDE's to auto-complete and validate configuration properties.
Installation
Phar (Recommended)
Download pre-bundled application from Releases
Composer
composer require ecomdev/mysql2jsonl
📜 License
This project is licensed under the MIT License.
See the LICENSE file for more details.