jdrvar

can a whereClause call multiple variables?

Discussion created by jdrvar on Jul 26, 2013
I am attempting to write a script that promts the user to enter 4 required and 2 optional values.  The first 4 fields are required and the last 2 are optional.  The values will be input as strings in ArcToolbox.  I was thinking I could use a whereClause and use the and operator to call the fields.  Then, select and zoom to record. I get an invalid syntax error.  Any suggestions with the whereClause? 

#Import
import arcpy

#Variables
TOWNSHIP = arcpy.GetParameterAsText(0)
RANGE = arcpy.GetParameterAsText(1)
SEC = arcpy.GetParameterAsText(2)
SUBCODE = arcpy.GetParameterAsText(3)
BLOCK = arcpy.GetParameterAsText(4)
LOT = arcpy.GetParameterAsText(5)

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Parcels", df)[0]

#Logic
try:
 whereClause = ""TOWNSHIP" = and "RANGE" and "SEC" and "SUBCODE" and "BLOCK" and "LOT" = '"+Parcels+"'"
 arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", whereClause)
 df.extent = lyr.getSelectedExtent()
 df.scale = df.scale*1.1

except:
 print arcpy.GetMessages()

Outcomes