Python Check If Substring Exists Sql Query To Insert