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?