Update attribute based on SQL table?

06-01-2021 09:25 AM
New Contributor III

I have a python script that runs periodically that updates a "status" attribute based on location relative to another feature class.

I have a SQL table that has a list of individual exceptions, where the status is not determined solely by location. 

Both the feature class that I'm trying to update and the SQL table have a unique identifier. How can I change the attribute based on the unique identifier's presence in the other table?

For example, the house with the unique ID# 12345 is updated to "available" because it within the determined distance of a property I just bought. However, I am uninterested in red houses. The table of red houses lists #12345. I need to change #12345 back to "unavailable" because it's in the list. 

0 Kudos
1 Reply
Regular Contributor

Maybe something like this to get you started...




fc = "fc"
fc1 = "fc1"

fcH_ID = []
fc1H_ID = []

with arcpy.da.SearchCursor(fc, ["House_ID"]) as cursor:
    for row in cursor:

del row, cursor

with arcpy.da.SearchCursor(fc1, ["House_ID"]) as cursor:
    for row in cursor:
        if not row[0] in fcH_ID:

del row, cursor

for ID in fc1H_ID:
    arcpy.SelectLayerByAttribute_management(fc1, "ADD_TO_SELECTION", "House_ID = " + str(ID) # and House_ID = "Red"



0 Kudos