Load SQL View on ArcMap, using Python

203
0
02-23-2018 08:23 AM
Autoridad_Nacional_del_AguaANA
New Contributor II

I want to add a sql view, generated in slq server, on ArcMap document, through python script.

My sql view has this fields:

My script is:

import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")

df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]

lyr = arcpy.mapping.Layer(r'Database Connections\xxxxx.sde\xxxx.dbo.Lay1')

arcpy.mapping.AddLayer(df,lyr)

This script load lyr on ArcMap temporaly, but when I want to acces to Attribute table, see this error:

I don´t know how to indicate to python, wich field from Lay1 contain oid, in my case OBJECTID field.

 

I guess your help, thanks.

Tags (2)
0 Kudos
0 Replies