Skip to content

hughedward/easy_output_insert_sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

easy_output_insert_sql

MySQL Query Result to INSERT Converter

image

中文 | English

一个简单但实用的工具,用于将 MySQL 查询结果转换为 INSERT 语句。

功能特点

  • 自动将 MySQL 终端输出格式转换为可执行的 INSERT 语句

  • 智能处理 NULL 值和空字符串

  • 自动识别表名(基于文件名)

  • 支持 UTF-8 编码

  • 保留原始列名顺序

  • 自动处理字符串转义

使用方法

  1. 基础用法:
$ python getSqlInsert.py your_query_result.txt
  1. 输入文件格式示例(MySQL 查询结果):
+----+-----------+--------+
| id | name      | status |
+----+-----------+--------+
| 1  | test      | active |
| 2  | NULL      | NULL   |
| 3  |           | pause  |
+----+-----------+--------+
  1. 输出结果示例:
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 License

作者

qiuYeBai(hugh.edward)
hughadward123@gmail.com

更新日志

2024/01/24: 初始版本发布
2024/01/06: 简单修改

trans select results into "insert into xxx" format

You can also view me in CSDN qiuyebai

such as this: image

Star History

Star History Chart

About

trans select results into "insert into xxx" format

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages