Norton

User Input into Selection Expression

Discussion created by Norton on Oct 20, 2011
Latest reply on Oct 21, 2011 by jskinner-esristaff
I am trying to write a script that will simply get (1) a county name and (2) and tax parcel ID. These values (stored as variables) need to be used in a SQL expression for the Select by Attribute dialog. This model needs to run in ArcMap, so I'm not sure if the "input" is correct usage and whether I've properly written the SQL expression to handle the variables (county name, parcel ID).
________________________________

# Import modules
import arcpy
import sys


# Set local variables
parcels="Parcels"

# Ask user for the County and Parcel ID to search
county = input("Please type either WARREN, WASHINGTON, OR ESSEX: ")
key = input("Please type the Parcel ID: ")

# User selects COUNTY and then Print Key value, Select by Attribute tool runs
    arcpy.SelectLayerByAttribute_management(Parcels, "NEW_SELECTION", "[COUNTY] = 'county' AND [PRINT_KEY] = 'key'")

Outcomes