AnsweredAssumed Answered

Do I need to be in a edit session to use the Insert Cursor?

Question asked by ionarawilson on Jul 26, 2013
Latest reply on Aug 2, 2013 by ionarawilson
I am inserting rows in a table, but it only works if I am in a edit session. However all the examples I see are not in an edit session. How can I have an insertcursor without an edit session? if I have to be editing, what would be the workspace for my SDE geodatabase? Later, I will actually have a feature service, but for now I need to set up a workspace for a table in a SDE Geodatabase.

What would be the expression for arcpy.env.workspace = ?

Thanks

         #Sets parameters (attributes)     County = gp.GetParameterAsText(0)     Office =  gp.GetParameterAsText(1)     Forester = gp.GetParameterAsText(2)     DateComplete = gp.GetParameterAsText(3)     RecipientLast = gp.GetParameterAsText(4)     RecipientFirst = gp.GetParameterAsText(5)     Acres = gp.GetParameterAsText(6)     Underserved = gp.GetParameter(7)      field = ["FIPS_TXT"]     with arcpy.da.SearchCursor("Counties", field) as rows:       for row in rows:            Countytxt = row[0]        sCursor = arcpy.SearchCursor("CountyLevelActivity")     for row in sCursor:          # Create domains         # This is to send the code to the database but keep the description for the user input          officeDomain = {'Alpine': 'AL', 'Austin': 'AU', 'Carthage': 'CA', 'Corpus Christi': 'CC', 'Conroe': 'CO', 'Crockett': 'CR',                               'Crockett':'CR', 'College Station': 'CS', 'Canyon': 'CY', 'Dallas': 'DA', 'El Paso': 'EP', 'Fort Worth': 'FW',                               'Gilmer': 'GI', 'Granbury': 'GR', 'Hamilton': 'HA', 'Henderson': 'HE', 'Houston': 'HO', 'Hudson': 'HU',                               'Huntsville': 'HV', 'Idalou': 'ID', 'Jacksonville': 'JA', 'Johnson City': 'JC', 'Jasper': 'JS', 'Kerrville': 'KE',                               'Kirbyville': 'KI', 'La Grange': 'LG', 'Linden': 'LI', 'Longview': 'LO', 'Lufkin': 'LU', 'Livingston': 'LV',                               'Marshall': 'MA', 'Magnolia Springs': 'MS', 'Nacogdoches': 'NA', 'New Boston': 'NB', 'Olive': 'OL', 'Overton': 'OV',                               'Palestine': 'PA', 'Pittsburg': 'PI', 'San Antonio': 'SA', 'San Augustine': 'ST', 'San Angelo': 'SG', 'Temple': 'TE',                               'Weslaco': 'WE'}         OfficeCode= officeDomain[Office]         foresterDomain = {'Brittany Compton': 'bcompton', 'Brian Pope': 'bpope', 'Buster Robinson': 'brobinson',                                 'Clay Bales': 'cbales', 'Daniel Duncum': 'dduncum', 'Daniel Lewis': 'dlewis',                                 'Eric Beckers': 'ebeckers', 'Jason Ellis': 'jellis', 'Jared Goodman': 'jgoodman',                                 'John Hawkins': 'jhawkins', 'Jordan Herrin': 'jherrin', 'Jim Houser': 'jhouser',                                 'John Matel': 'jmatel', 'Juan Merriweather': 'jmerriweather', 'Jonathan Motsinger': 'jmotsinger',                                 'John Parker': 'jparker', 'John Warner': 'jwarner', 'Mark Duff': 'mduff',                                 'Michael Easley': 'measley', 'Matt Wright': 'mwright', 'Penney Bartley': 'pbartley',                                 'Phil Gates': 'pgates', 'Renne Burks': 'rburks', 'Rich Dottellis': 'rdottellis',                                 'Robert Edmonson': 'redmonson', 'Rob Grotty': 'rgrotty', 'Russell Lykins': 'rlykins',                                 'Rachel McGregor': 'rmcgregor', 'Todd Nightingale': 'tnightingale', 'Zaina Gates': 'zgates',                          }          ForesterCode = foresterDomain[Forester]         UnderservedDomain = {'Yes': '1', 'No': '0'}         UnderservedCode = UnderservedDomain[Underserved]        irows = arcpy.InsertCursor("CountyLevelActivity")      irow = irows.newRow()     irow.CountyActivity = Countytxt     irow.Office = OfficeCode     irow.Forester = ForesterCode     irow.DateComplete = DateComplete     irow.RecipientLast = RecipientLast     irow.RecipientFirst = RecipientFirst     irow.Acres = Acres     irow.Underserved = UnderservedCode     irows.insertRow(irow)         #Refresh Map to refelct Changes     arcpy.RefreshActiveView()     #mxd.save()      #del mxd,

Outcomes