When building a SQL audit system, I want to compress the SQL statements entered by users (for storage in DB) and beautify (for interface display).
I found two python-related libraries:
`python-sqlparse` 这个库对简单的一些select语句美化效果还可以,但是稍微复杂一点的SQL,美化的效果不明显,比如这样的SQL: CREATE TABLE `t1` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='测试表1'; `pygmentize`: 这个库缺点太多
Do you have any relevant libraries to recommend? JS related libraries can also be used
To beautify SQL, you can use the above sqlparse. As for sql compression, you can achieve it by removing redundant strings.