POST
|
Here is my code
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.name == 'test':
if lyr.supports("SERVICEPROPERTIES"):
servProp = lyr.serviceProperties
path = 'D:\\temp'
connection = "ttene71.sde"
fc = "test"
where = 'OBJECTID = 1' #35585
arcpy.CreateDatabaseConnection_management(path,connection,"ORACLE",<instance>,"DATABASE_AUTH",<user_name>,<password>,"SAVE_USERNAME","",<password>,"TRANSACTIONAL",<version_name>,"")
dbc = 'Database Connections//test1.sde'
workspace = os.path.dirname(dbc)
editor = arcpy.da.Editor(workspace)
editor.startEditing(False,True)
editor.startOperation()
cursor = arcpy.da.UpdateCursor(lyr,['OBJECTID','NAME'], where)
for row in cursor:
row[1] = '222'
cursor.updateRow(row) # getting the error here
del row
del cursor
editor.stopOperation()
editor.stopEditing(True)
del editor
del mxd
... View more
02-07-2018
04:26 AM
|
0
|
0
|
2009
|
POST
|
Manually I'm able to edit the data. While using arcpy I'm facing error.
... View more
02-07-2018
04:11 AM
|
0
|
0
|
2925
|
POST
|
I'm using Updatecursor logic all are working fine but while updating the row its getting failed at the statement RuntimeError: The requested operation is invalid on a closed state import arcpy
import os
fc = 'Database Connections/Portland.sde/portland.jgp.schools'
workspace = os.path.dirname(fc)
# Start an edit session. Must provide the workspace.
edit = arcpy.da.Editor(workspace)
# Edit session is started without an undo/redo stack for versioned data
# (for second argument, use False for unversioned data)
edit.startEditing(False, True)
# Start an edit operation
edit.startOperation()
# Insert a row into the table.
with arcpy.da.UpdateCursor(fc, ('Name')) as ucur:
for row in ucur:
row[1] = '222'
ucur.updateRow(row) # Failing at this case
# Stop the edit operation.
edit.stopOperation()
# Stop the edit session and save the changes
edit.stopEditing(True)
... View more
02-07-2018
04:09 AM
|
0
|
1
|
2009
|
POST
|
While updating the field using update cursor. Getting the error:The requested operation is invalid on a closed state. Here is my code: editor = arcpy.da.Editor(workspace) editor.startEditing(False, True) editor.startOperation() cursor = arcpy.da.UpdateCursor(<>feature_class,[<fields>]) for row in cursor: # updation stuff comes here cursor.updateRow(row) del row del cursor editor.stopOperation() editor.stopEditing(True) del editor I appreciate any help or suggestions.
... View more
02-07-2018
12:53 AM
|
0
|
5
|
3248
|
POST
|
Here is my sample code path = 'D:\\temp' connection = "test1.sde" arcpy.CreateDatabaseConnection_management(path, connection, "ORACLE", instanse, "DATABASE_AUTH", "test", XXX, "SAVE_USERNAME", "", database, "TRANSACTIONAL", <version_name>,"") tablePath = path + "\\" + connection arcpy.env.workspace = tablePath with arcpy.da.UpdateCursor(arcpy.env.workspace,[<field_name>], where) as cur: # updatecursor stuff come here
... View more
02-06-2018
08:16 PM
|
0
|
1
|
2009
|
POST
|
Hi Xander, Thanks for ur reply. Yes, It is editing manually with the standard license. Thanks, Kamyaka
... View more
02-06-2018
05:07 AM
|
0
|
2
|
2009
|
POST
|
Getting the error "cannot open workspace" while using arcpy.da.Editor(arcpy.env.workspace) for a versioned data Can anyone help on this. Thanks, Kamyaka
... View more
02-06-2018
04:39 AM
|
0
|
10
|
3604
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|