Python Check If Substring Exists Sql Query Checker