mapmike

Error running simple Python script with SQL Expression Argument from Command Line

Discussion created by mapmike on Dec 2, 2010
Latest reply on Dec 3, 2010 by rdharles
enerated simple script to run from command line. (attached sample.py)

Built in model builder, works in model builder. Selecting features using a SQL Expression and exporting to new feature class. Works when SQL Expression is not model parameter. Does not work when it is a parameter. In command prompt using correct usage of: sample.py "UTC" > 1

Model returns error. Tried using several ways of typing argument into command line, all fail:
"\"UTC\" > 1 "
"\"UTC\" >= 1"

Please help.

Thank you!! Seems to work on everything but expressions?

Mike Thompson 781-545-8026 x205 michael.a.thompson@noaa.gov

# ---------------------------------------------------------------------------
# sample.py
# Created on: 2010-12-02 15:02:34.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: sample <SQLExpression>
# Description:
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Script arguments
SQLExpression = arcpy.GetParameterAsText(0)

# Local variables:
sourcedata = "T:\\scratch.gdb\\sourcedata"
output = SQLExpression

# Process: select
arcpy.Select_analysis(sourcedata, output, SQLExpression)

Outcomes