-
A simple yet practical tool that converts MySQL query results into executable INSERT statements. This tool streamlines the process of data migration and testing by transforming query outputs into reusable SQL commands.
-
Automatic Conversion: Transforms MySQL terminal output format directly into executable INSERT statements
-
Smart Value Handling: Intelligently processes NULL values and empty strings while maintaining data integrity
-
Dynamic Table Recognition: Automatically detects table names from input filenames for convenience
-
Universal Encoding: Full UTF-8 support for international character sets
-
Column Order Preservation: Maintains the original column sequence from your query results
-
Safe String Processing: Automatic string escaping to prevent SQL injection and syntax errors
-
- Basic usage:
python getSqlInsert.py your_query_result.txt- Input File Format Example (MySQL Query Result):
+----+-----------+--------+
| id | name | status |
+----+-----------+--------+
| 1 | test | active |
| 2 | NULL | NULL |
| 3 | | pause |
+----+-----------+--------+- Output Example:
INSERT INTO table_name (id, name, status) VALUES ('1', 'test', 'active');
INSERT INTO table_name (id, name, status) VALUES ('2', NULL, NULL);
INSERT INTO table_name (id, name, status) VALUES ('3', '', 'pause');git clone https://github.com/hughedward/easy_output_insert_sql.git
cd mysql-insert-converterPython 3.6+
No external dependencies requiredFeatures Status:
[x] Automatic column name recognition
[x] Smart NULL value handling
[x] UTF-8 support
[x] Command line interface
[ ] Custom output filename
[ ] Batch file processingIssues and Pull Requests are welcome! Feel free to contribute to this project.MIT LicenseqiuYeBai(hugh.edward)
hughadward123@gmail.com2024/01/24: Initial version released
2025/01/06: fixestrans select results into "insert into xxx" format
You can also view me in CSDN qiuyebai
