AnsweredAssumed Answered

connect to enterprise geodatabase in script

Question asked by jpilbeam Champion on Aug 6, 2019
Latest reply on Aug 7, 2019 by LanceCole

This question is based off of another one I just had.


I can't seem to update a feature dataset in a sql server enterprise geodatabase. I have sysadmin user role access to the database. One thing I've tried is copying the path of the connection file from an ArcPro project and using that in the script. This particular script here works perfect if I use it on a file geodatabase inside a folder. Basically, I'm not sure how to connect to the enterprise geodatabase.


update the feature classes in the feature dataset gisedit.DBO.dFIRM_2019_Effective
from the shapefiles in this directory:

import arcpy
from arcpy import env
import os

#shapefile variable
shp = r'\\gisfile\GISsources\Federal\FEMA\DFIRM\
#sde connection file variable
sde = r'C:\Users\jpilbeam\AppData\Local\Temp\ArcGISProTemp11396\

env.workspace = shp
#populate the fcList
fcList = arcpy.ListFeatureClasses()

env.workspace = sde
env.overwriteOutput = True
#iterate list of shapefiles and copy to sde feature dataset
for shapefile in fcList:
    in_shapefile = os.path.join(shp, shapefile)
    out_featureclass = os.path.splitext(shapefile)[0]
    print('Copying %s to %s' %(in_shapefile, out_featureclass))
    arcpy.CopyFeatures_management(in_shapefile, out_featureclass)


Traceback (most recent call last):
  File "\\gisfile\GISstaff\Jared\Python Scripts\ArcGISPro\", line 30, in <module>
    arcpy.CopyFeatures_management(in_shapefile, out_featureclass)
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\", line 2948, in CopyFeatures
    raise e
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\", line 2945, in CopyFeatures
    retval = convertArcObjectToPythonObject(gp.CopyFeatures_management(*gp_fixargs((in_features, out_feature_class, config_keyword, spatial_grid_1, spatial_grid_2, spatial_grid_3), True)))
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\", line 506, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000733: Output Feature Class: Same as input Input Features
Failed to execute (CopyFeatures).


I forgot to mention that the shapefiles and the features in the dataset have the same names. I need to update the dataset every month with these shapefiles.