sql-comment-parser

Crates.iosql-comment-parser
lib.rssql-comment-parser
version0.1.0
sourcesrc
created_at2024-03-17 12:20:55.133977
updated_at2024-03-17 12:20:55.133977
descriptionsql comment parser
homepagehttps://github.com/wpf375516041/sql-comment-parser
repository
max_upload_size
id1176434
size20,884
秦歌 (wpf375516041)

documentation

README

软件介绍

移植于: https://github.com/wangjie-fourth/SqlParser/blob/main/src/main/java/myself/SqlCommentParser.java

解析sql语句中的注释,具备以下两个能力:

  • 提取sql中的注释(✅)
  • 移除sql中的注释(✅)

快速使用

use sql_comment_parser::SqlCommentParser;

fn main() {
    let sql = "SELECT * FROM table--; -- This is a single line comment";
    let mut parser = SqlCommentParser::new(&sql);
    let comment_sql = parser.get_comment_sql();
    let cleaned_sql = parser.remove_comment_sql();
    println!("{}", cleaned_sql); //打印SELECT * FROM table
    println!("{}", comment_sql); //打印--; -- This is a single line comment
}

参考链接

https://wangjie-fourth.github.io/2021/01/30/experience/remove-comment-in-sql/

Commit count: 0

cargo fmt