javascript - Python or JS beautifies and compresses SQL statements
为情所困
为情所困 2017-05-18 10:48:12
0
1
599

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

为情所困
为情所困

reply all (1)
伊谢尔伦

To beautify SQL, you can use the above sqlparse. As for sql compression, you can achieve it by removing redundant strings.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!