1

I am trying to create a python script to copy data from a MSSQL view (includes a geometry field) into a feature class. They are both held within the same database.

I have tried arcpy.CopyFeatures_management and get the following error:

ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset \Virgis01\gis\Naomi-AssetFindaTest\TaupoGISTest.dbo.AF_VW_CCTVwastewater does not exist or is not supported WARNING 000725: Output Feature Class: Dataset \Virgis01\gis\Naomi-AssetFindaTest\TaupoGISTest.sde\TaupoGISTest.DBO.CCTV\TaupoGISTest.DBO.CCTV_Polyline_Copy already exists. Failed to execute (CopyFeatures).

I have tried arcpy.Append_management and get the following error:

ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Target Dataset: Dataset polyline does not exist or is not supported Failed to execute (Append).

I have tried arcpy.CopyRows_management and get the following error:


ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Rows: Dataset \Virgis01\gis\Naomi-AssetFindaTest\TaupoGISTest.dbo.AF_VW_CCTVwastewater does not exist or is not supported WARNING 000725: Output Table: Dataset \Virgis01\gis\Naomi-AssetFindaTest\TaupoGISTest.sde\TaupoGISTest.DBO.CCTV\TaupoGISTest.DBO.CCTV_Polyline_Copy already exists. Failed to execute (CopyRows).


This is my code:

import arcpy
import os

arcpy.env.overwriteOutput = True

source_path = r'\\Virgis01\gis\Naomi-AssetFindaTest\TaupoGISTest.dbo.'
output_path = r'\\Virgis01\gis\Naomi-AssetFindaTest\TaupoGISTest.sde\TaupoGISTest.DBO.CCTV\TaupoGISTest.DBO.'

polyline = output_path+r'CCTV_Polyline_Copy'

views = [r'AF_VW_CCTVwastewater', r'AF_VW_CCTVstormwater']

for view in views:
    print 'processing ' + view + '             o   o'
    print 'deleting                                      >  '
    #arcpy.TruncateTable_management(polyline)
    print 'copying                                    \_____/'
    #arcpy.CopyRows_management(source_path+view, polyline)
    #arcpy.Append_management("source_path+view", "polyline", "TEST")
    arcpy.CopyFeatures_management(source_path+view, polyline)

Are there another alternative that will turn this query layer into a feature class and bypass this error?

9
  • please edit your Question and include a snippet of your code that isn't working
    – Midavalo
    Commented Jun 2, 2016 at 23:55
  • 1
    arcpy.env.overwriteOutput = True will help (possibly) with your feature class already existing. What database is it? it looks like SDE but with a UNC path with only one slash '\', is that path truly valid? Are you sure you're escaping your strings properly? Commented Jun 3, 2016 at 0:06
  • Hi @MichaelMiles-Stimson I've just added in my script. You will see that the overwrite function is already part of the script and that my paths have two slashes - yet why does the error message only show one??
    – N. Begg
    Commented Jun 3, 2016 at 0:36
  • @Midavalo I have added my code.
    – N. Begg
    Commented Jun 3, 2016 at 0:39
  • 2
    They're still invalid without a connection file, which is what the error states.
    – Vince
    Commented Jun 3, 2016 at 3:11

1 Answer 1

2

Thanks for the above comments, this has helped me with a solution.
The problem was in the source paths but there was also problems with overwriting.

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.