[docs]deflooks_like_sql(s:str)->bool:""" Determine if string `s` looks like an SQL query. :param str s: The string to detect. :return: True if the string looks like an SQL, False otherwise. """sql_keywords={"select","update","union","delete","from","table","insert","into"}s=s.lower()forkinsql_keywords:ifkins:k_index=s.find(k)# what's before k? is it a whitespace if it's not empty?ifk_index>0:before=s[k_index-1]ifbeforenotin" /;":continue# what's after k? is it a whitespace?following=s[k_index+len(k):]ifnotfollowingorfollowing.startswith(" "):returnTruereturnFalse