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.
Code:
#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
gdbCursor.insertRow(row)