export a feature class to .shp - unable to connect to sql server with python

297
2
09-14-2021 10:07 AM
BobNoyes
New Contributor III

I am trying to upgrade a script I use in ArcMap to ArcGIS Pro. I am not able to get it to recognize the the path to our sql server which houses the feature class I want to access. The script work fine in ArcGIS Map but I get errors when trying in ArcGIS Pro.
BobNoyes_0-1631638672001.png

This is a script that will have multiple lines but the first step is creating problems. Also, I ran the export tool on the feature class in pro and it worked fine. I then copied the snippet from the results and pasted it into the script (using PyCharm). 

Here is the script as it stands so far:

import arcpy

try:
in_table = r'Database Connections\GIS Update.sde\GIS_update.dbo.Orion_Taxlots\GIS_update.dbo.Orion_Taxlots'
in_data = r'Database Connections\JOCO B Marial.sde\jocoB_Production.DBO.POLY\jocoB_Production.DBO.poly_gon'
out_path = r"C:\GIS\Substage"
out_shp = "jocoB_Production_DBO_poly_gon.shp"
TL = r"C:\GIS\Substage\jocoB_Production_DBO_poly_gon.shp"
Out_Taxlots = "C:\\GIS\\Substage\\Taxlots.shp"

# Step 1 jocoB poly_gon copied to C:\GIS\Substage
arcpy.FeatureClassToShapefile_conversion(in_data, out_path)
print("Step 1 complete")

# Step 2 Dissolve TL.shp on MNX as Taxlots.shp
arcpy.Dissolve_management(in_features=TL, out_feature_class=Out_Taxlots, dissolve_field="MNX",statistics_fields="#", multi_part="MULTI_PART", unsplit_lines="DISSOLVE_LINES")

print("Step 2 complete: dissolved TL.shp on MNX, save as Taxlots.shp")
except Exception as e:
print("Error: " + e.args[0])

 

0 Kudos
2 Replies
MichaelVolz
Esteemed Contributor

I would make sure you are using the correct connection for Pro (In Oracle ats least you needed to use a 64-bit client instead of a 32-bit client).

I would use the actual path to the database connection c:\... instead of shorthand path which definitely works in ArcMap but I do not thinks works with Pro due to its different architecture.

in_table = r'Database Connections\GIS Update.sde\GIS_update.dbo.Orion_Taxlots\GIS_update.dbo.Orion_Taxlots' 

 

0 Kudos
BobNoyes
New Contributor III

Thanks. We are using Microsoft sql server and its at 64 bit. I am not sure what you mean when you say the actual path and use the C:\ drive prompt. This is not something I have ran across before. In the past it was as easy as copying and pasting the path from ArcCatalog..... Thanks again.

0 Kudos