Skip to content

数据库结构化比对,通过对数据库生成的结构化SQL文件比对,生成同步数据库的DDL语句,包含表和新增字段(Database structured comparison generates DDL statements for synchronized databases, including tables and new fields, by comparing the structured SQL files generated by the database)

Notifications You must be signed in to change notification settings

QinJun-IOC/MySQLStructuredComparison

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

MySQLStructuredComparison

数据库结构化比对,通过对数据库生成的结构化SQL文件比对,生成同步数据库的DDL语句,包含表和新增字段(Database structured comparison generates DDL statements for synchronized databases, including tables and new fields, by comparing the structured SQL files generated by the database)

预设使用脚本原因: 现有两个系统的数据库,旧系统的数据库老旧,希望同步新系统的数据库结构到旧系统,并且不影响旧系统对原库的使用.

脚本工作原理,在脚本当前目录,读取source_schema.sql和target_schema.sql,例如source_schema.sql为新系统导出数据库结构文件,target_schema.sql为旧系统导出数据库结构文件,脚本会以source_schema.sql结构为基准,比对target_schema.sql中不存在的表格,和相同表格下缺少的字段,在当前目录生成DDL文件(目前忽略了同字段不同类型或字段的判断,为了泛用化使用文件比对,需要的可以自行增加判断和使用connector的形式获取结构化信息).

执行命令:python diff_dateBases.py.

使用脚本环境需要python3,文件UTF-8.

(Reason for using the preset script:

There are two existing systems' databases, the old system's database is old, and we hope to synchronize the database structure of the new system to the old system without affecting the old system's use of the original database

The working principle of scripts is to read the source in the current directory of the script_ Schema.sql and target_ Schema.sql, such as source_ Schema.sql exports the database structure file for the new system, target_ Schema.sql exports the database structure file for the old system, and the script will start with source_ Using the schema.sql structure as a benchmark, compare the target_ Generate a DDL file in the current directory for tables that do not exist in schema.SQL and fields that are missing under the same table (currently ignoring the judgment of different types or fields in the same field. In order to use file comparison for generalization, it is necessary to add judgment and use the form of connectors to obtain structured information)

Execute command: Python diff_ DateBases. py

Using the script environment requires Python 3 and UTF-8 as the file)

About

数据库结构化比对,通过对数据库生成的结构化SQL文件比对,生成同步数据库的DDL语句,包含表和新增字段(Database structured comparison generates DDL statements for synchronized databases, including tables and new fields, by comparing the structured SQL files generated by the database)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages