QueryRow

摘要

QueryRow 对象可用于访问 queryJobs 方法结果中一行内的所有值。

说明

可通过索引、字段名称或迭代器从 QueryResult 中访问 QueryRow 对象。

代码示例

QueryRow 示例

以下脚本运行作业查询并访问查询行。

import arcpy

#Establish a connection to a Workflow database
conn = arcpy.wmx.Connect(r'c:\test\Workflow.jtc')

#Run a query for jobs being assigned to current user. The query results are sorted by job name.
result = conn.queryJobs("JOB_NAME,ASSIGNED_TO","JTX_JOBS","Job Name,Assigned To", "ASSIGNED_TO = '[SYS:CUR_LOGIN]'", "JOB_NAME")

#To get total number of records being returned which are assigned to current user.
print("There are %s jobs assigned to me" % str(len(result.rows)))


# Access first row by index 
print ("The first value is %s" % str(result.rows[0]))

# Access first row's job name field by field name
print ("The job name is %s" % result.rows[0]['JOB_NAME'])

# Access first row's fields values by iterator
row = result.rows[0]
for val in row:
    print("Value is %s" % str(val))

在本主题中