Is there any third-party tool for validate SQL query before I execute it with the database/sql pacakge or any way to check the SQL query is right without getting a panic from database/sql that the query is invalid?
1条回答 默认 最新
dongzhi4239 2017-02-27 12:55关注Finally, I found this SQL parser package. I colud use it for validate it.
func isSQLValid(sql string) (bool, error) { _, err := sqlparser.Parse(sql) if err != nil { return false, err } return true, nil }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报