I've written several scripts that copy data from MS Access db into a new, empty ESRI Geodatabase. I've pretty much copied the code and changed it for each table -- the first two scripts have worked as expected, but the third is throwing an error on the line used to create the Insert Cursor.

All of the variables are storing correctly at the top of the script, but the Insert Cursor is never created.

Error Message:

Runtime error Traceback (most recent call last):

File "", line 49, in File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy__init__.py", line 1005, in InsertCursor return gp.insertCursor(dataset, spatial_reference)

File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\geoprocessing_base.py", line 383, in insertCursor self._gp.InsertCursor(*gp_fixargs(args, True)))

RuntimeError: ERROR 999999: Error executing function.


#Import modules, environment settings
import arcpy
arcpy.env.overwriteOutput = True

# Database connection variables
geodatabase = 'P:/GIS_Development/ArcGIS Database Design/Landowner.gdb/Parcels'
accessDatabase = 'Y:/Database/LANDOWNER/NewLandowner.mdb/TblParcels'

#Create cursor for ACCESS Database and New Landowner GDB
accessCursor = arcpy.SearchCursor(accessDatabase)

# Create a variable that stores the value for column in a given row in the access table

for accessRow in accessCursor:

    parcelID   = accessRow.getValue('Parcel_ID')
    flag       = accessRow.getValue('Flag')
    agreeID    = accessRow.getValue('Agreement_ID')
    agreeStat  = accessRow.getValue('AgreementStatus')
    ownerType  = accessRow.getValue('Owner_Type')
    add1       = accessRow.getValue('Parcel_Address1')
    city       = accessRow.getValue('Parcel_City')
    county     = accessRow.getValue('Parcel_County')
    state      = accessRow.getValue('Parcel_State')
    zipCode    = accessRow.getValue('Parcel_Zip')
    acreage    = accessRow.getValue('Acreage')
    landClass  = accessRow.getValue('Land_Class')
    mapGrid    = accessRow.getValue('Map_Grid')
    parcelNum  = accessRow.getValue('Parcel_Num')
    parcelCom  = accessRow.getValue('Parcel_Comments')
    enterRes   = accessRow.getValue('Entry_Restrict')
    enterCom   = accessRow.getValue('Entry_Comments')
    contacted  = accessRow.getValue('Contact_Made')
    appStatus  = accessRow.getValue('ApprovalStatus')
    owner      = accessRow.getValue('Owner')

    # "Paste" the stored value from the access table into the new geodatabase
    gdbCursor = arcpy.InsertCursor(geodatabase)
    row = gdbCursor.newRow()

    if state:
        state = state.upper()

    #Fill out fields with variables that are storing MS Access data
    row.Parcel_ID            = parcelID
    row.Flag                 = flag
    row.Agreement_ID         = agreeID
    row.Agreement_Status     = agreeStat
    row.Owner_Type           = ownerType
    row.Address_Line_1       = add1
    row.City                 = city
    row.County               = county
    row.State                = state
    row.Zip_Code             = zipCode
    row.Acreage              = acreage
    row.Land_Classification  = landClass
    row.Map_Grid             = mapGrid
    row.Parcel_Number        = parcelNum
    row.Parcel_Comments      = parcelCom
    row.Entry_Restrictions   = enterRes
    row.Entry_Comments       = enterCom
    row.Contact_Made         = contacted
    row.ApprovalStatus       = appStatus

    # Insert new row into Geodatabase
  • Roy, I get exact same error as you have got, can you please help by explaining what you mean by adding insert cursor manually? Thanks for any help P.S : I do not see an option to comment, will change this answer to comment later... sorry for inconvenience ...
    – mayank
    Commented Feb 21, 2013 at 12:44
  • This was almost a year ago, I can't really remember the context of the solution. You might be better served to post your own question including your code!
    – Roy
    Commented Feb 21, 2013 at 16:31

3 Answers 3


Python isn't really the right tool for the job here. If I were you, I'd do this with Featureclass To Featureclass or Append, there is little to no benefit of doing this in Python when a geoprocessing tool exists to already do this and will run faster than a Python script.

  • Thanks -- I guess table to table would have worked here (these aren't feature classes, but related tables for a fc). Setting it up this way I felt that I had more control over field properties like type, length, default values, etc.
    – Roy
    Commented May 4, 2012 at 15:10

I'm thinking that the line "accessRow = accessCursor.next()" is not needed. This was how you got your row object at 9.3 arggisscripting. Now at arcpy this is not needed. From what I remember before the cursor would return an enumeration and now they return a list. Now we don't while through we just say for x in list.

Hopefully some of our more pythonista bretheren on GIS.se can correct or update my statements.

Hope it helps.

Check this out.

  • You're absolutely right -- I tried switching from a 'while' loop to a 'for' loop (shot in the dark) and left that line in by mistake. Unfortunately without it, the code still doesn't run (same error). I'll update the sample code accordingly.
    – Roy
    Commented Mar 30, 2012 at 12:31
  • Sooooo, some additional debugging did the trick. I added the insert cursor manually into the Python window in ArcMap 10 -- it worked just fine. That led me to believe that the variable 'geodatabase' (the path to the table) was somehow invalid despite copying the location from ArcCatalog? When I replaced the path variable with the name of the table in the actual MXD, the script ran correctly and it copied over my 900 records. Strange.
    – Roy
    Commented Mar 30, 2012 at 13:01
  • Oh right, sorry I didn't read carefully enough. When I copy from catalog I generally do path = r"Database Connections\sde__ServerMachine_sde__MSSQL.sde\nameOfFC"
    – Justin
    Commented Mar 30, 2012 at 13:08
  • @Rob: your paths need to have either a double forward slash // or use the r option and use single backslashes like @Justin has in the comment above. Commented Mar 30, 2012 at 13:44
  • 1
    I thought it was either a single forward slashes, double back slashes or single backslashes with r.
    – Justin
    Commented Mar 30, 2012 at 13:46

Thanks Roy for responding to it, I luckily found a solution to the problem. Just so it helps others that may make same mistake as i did, here's the issue and solution:

I had posted a comment earlier about the same error I had got. The reason for my error was that I wanted to create a new polyline file by connecting some points in a point shapefile. Earlier the polyline was did not exist. I wanted to create a new one with insertcursor. The fact that the file was non-existent caused the problem. Lot of googling gave me answer hidden here:

NIM060202 - Functions that have an input data parameter such as Describe, ListFields, SearchCursor and several others, all fail with a "ERROR 999999: Error executing function." if the data does not exist.

In my case, it was insertcursor that caused the problem. It went into finding gdal16.dll and various gdalplugins for some reason. But as soon as I gave it an empty shapefile, it stopped complaining and did the trick for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.