That is where I found the "AttributeError: object has no attribute '_arc_object'" error being called.
check = LayerSite.supports("DEFINITIONQUERY")
If I change it to string, it gives the same error, just with 'str' instead of unicode.
I saved a python module that has the syntax pre-set
def BuildQuery(table, field, operator, value=None): """Generate a valid ArcGIS query expression arguments table - input feature class or table view field - field name (string) operator - SQL operators ("=","<>", etc) "IS NULL" and "IS NOT NULL" are supported value - query value (optional) examples >>> BuildQuery("x.dat","FIELD1","=", "spam") u'"FIELD1" = \'spam\'' >>> BuildQuery("x.dat","FIELD1",">",42) u'"FIELD1" > 42' BuildQuery(r"E:\tables.mdb\table1","PwsID","IS NOT NULL") u'[PwsID] IS NOT NULL' """ # Use correct field delimeter (depends on table type) # For 9.3, use "gp" instead of "arcpy" in the following line qfield=arcpy.AddFieldDelimiters(table,field) # tweak value delimeter for different data types if type(value) == type("string"): # add single quotes around string values qvalue = "'" + value + "'" elif value == None: # drop value when not specified (used for IS NULL, etc) qvalue = "" else: # numeric values are fine unmodified qvalue = value sql = "%s %s %s" % (qfield,operator,qvalue) return sql.strip()
lyr.definitionQuery = "\"CellSiteID\" = '%s'" % pageName
lyr.definitionQuery = '"CellSiteID" = \'%s\'' % pageName
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.