AnsweredAssumed Answered

SQL Error arcpy.FeatureClassToFeatureClass

Question asked by lloydbronn on May 4, 2017
Latest reply on May 8, 2017 by lloydbronn

I have a Python GP tool on our Arc GIS Server that generates a report based on a polygon drawn on a web map. I have a query that sorts up to the top 15 cities in the region by population and creates a temporary shapefile of these cities. Everything works fine until I have a small enough region that only has one populated city. I get this error from the server logs:


An invalid SQL statement was used. An invalid SQL statement was used. The Project method cannot do a datum transformation. Failed to execute (FeatureClassToFeatureClass). 


I do not get this error if there are two or more populated cites in the region. Here is the Python snippet with the query. It's set to skip the temporary shapefile creation if there are no cities in the region. 


cities = temp_path + region_name + "\\" + "cities.shp"

values = [row[0] for row in arcpy.da.SearchCursor(cities, field)]
        top_cities = sorted(values)[-15:] #adjust max rows count   
        query = "\"{0}\" in {1}".format(field, tuple(top_cities))
        check_list = [cities,]

        for shapefile in check_list:
            if arcpy.GetCount_management(shapefile)[0] != 0:
                arcpy.FeatureClassToFeatureClass_conversion(cities,temp_path + region_name,"pop.shp",query)