Arcpy.python语言ArcServer sde权限

2024-06-16 12:43:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个python脚本,它基本上是通过一个点的ID来选择一个点,然后选择一个距离内的所有点,并且只返回与类型字段匹配的一个子集。i、 e.找到离这个地点3英里以内的所有医院。。在

我的python脚本可以工作,做它应该做的。所以我从中创建了一个家庭医生服务。将服务添加回映射并运行它。现在我注意到无论我使用什么距离,数据都不会改变。如果我删除创建的Featureclass,看看它是否真的有效。它没有创建一个新的featureclass,但它说它成功地完成了。在

奇怪的是,如果我用参数在rest端点上调用GP服务,它会说它可以工作,但不会返回任何记录。当使用Rest端点ArcMap和ArcCatalog被关闭时,我一直在小心地避免模式锁。在

这就像GP服务没有权限写入sde数据库,但是我的sde连接在我的PC上工作得很好

有什么想法吗?在

import arcpy, os, string
from arcpy import env

db = r"Connection to racdev1.sde" 
theworkspace = r"Connection to racdev1.sde" 
arcpy.env.workspace = theworkspace

arcpy.env.overwriteOutput = True

#facilityID = '1249'
facilityID = arcpy.GetParameterAsText(0)
#facilityIDType= 'PFI'
facilityIDType = arcpy.GetParameterAsText(1)

thedistance = arcpy.GetParameterAsText(2)
#thedistance = '3 miles'
#withindistance = "3 Miles"
withindistance =  thedistance + ' Miles'

sql_query = "\"%s\" = '%s'" % ("ID", facilityID)           
sql_query2 = "\"%s\" = '%s'" % ("IDTYPE", facilityIDType)

# Local variables:
Facilities = "DOHGIS.NYSDOH_CI_DATA"
featLayer = "thePts"

arcpy.MakeFeatureLayer_management(Facilities, featLayer)

# Process: Select Layer By Attribute
arcpy.SelectLayerByAttribute_management(featLayer, "NEW_SELECTION", sql_query)

# Process: Select Layer By Location  311
arcpy.SelectLayerByLocation_management(featLayer, "WITHIN_A_DISTANCE",featLayer, withindistance, "NEW_SELECTION")

#print " now for the subset"
arcpy.SelectLayerByAttribute_management("thePts", "SUBSET_SELECTION", sql_query2  )

# creaate the new featureclss.. 
arcpy.CopyFeatures_management("thePts",'DOHGIS.NYSDOH_FacilitiesQuery')
#print "Done"

Tags: env脚本idsqlmanagementarcpysdeselection