一个简单但实用的工具,用于将 MySQL 查询结果转换为 INSERT 语句。
-
自动将 MySQL 终端输出格式转换为可执行的 INSERT 语句
-
智能处理 NULL 值和空字符串
-
自动识别表名(基于文件名)
-
支持 UTF-8 编码
-
保留原始列名顺序
-
自动处理字符串转义
- 基础用法:
$ python getSqlInsert.py your_query_result.txt- 输入文件格式示例(MySQL 查询结果):
+----+-----------+--------+
| id | name | status |
+----+-----------+--------+
| 1 | test | active |
| 2 | NULL | NULL |
| 3 | | pause |
+----+-----------+--------+- 输出结果示例:
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-converter
Python 3.6+
无需其他外部依赖
[x] 自动识别列名
[x] 智能处理 NULL 值
[x] UTF-8 支持
[x] 命令行接口
[ ] 自定义输出文件名
[ ] 批量处理多个文件
欢迎提交 Issue 和 Pull Request!MIT LicenseqiuYeBai(hugh.edward)
hughadward123@gmail.com2024/01/24: 初始版本发布
2024/01/06: 简单修改trans select results into "insert into xxx" format
You can also view me in CSDN qiuyebai
