Sql Query To Find Substring Python