<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: arcpy and SDE outside of ArcGIS in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565385#M44267</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any resolution on this?&lt;/P&gt;&lt;P&gt;I am trying to automate the migration of data using geoprocessing tools.&amp;nbsp; So I am starting with an XML Workspace Document that I exported using ArcCatalog.&amp;nbsp; When I try to import this into a new geodatabase, I tried dragging the db connection into the geoprocessing tool (ImportXMLWorkspaceDocument) and it fails saying 'Cannot access local or remote database'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This happens with multple tools, i.e., EnableAttachments_management, Append_management and ImportXMLWorkspaceDocuemnt)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Jun 2016 19:38:52 GMT</pubDate>
    <dc:creator>RhondaGregory</dc:creator>
    <dc:date>2016-06-03T19:38:52Z</dc:date>
    <item>
      <title>arcpy and SDE outside of ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565378#M44260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having trouble accessing ArcSDE Feature Classes from Python running outside of ArcGIS 10.2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I put together a quick test script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import arcpy

# Test for existence of various datasets, both in SDE and shapefile
for pth in (r"Database Connections\GIS.sde",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r"C:\Users\RMcCulley\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\GIS.sde",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r"Database Connections\GIS.sde\gis.cvr.Basemap\gis.cvr.Townships",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r"G:\Parcel GIS Files\Townships.shp"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(pth):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = pth + " Exists"
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = pth + " Doesn't Exist"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(value)

# Try FeatureClassToFeatureClass to export from Shapefile to Shapefile
if arcpy.Exists(r"C:\Temp\Townships_From_SHP.shp"): 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(r"C:\Temp\Townships_From_SHP.shp")
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; value = arcpy.FeatureClassToFeatureClass_conversion(in_features=r"G:\Parcel GIS Files\Townships.shp",out_path=r"C:\Temp",out_name="Townships_From_SHP.shp")
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; value = "FeatureClassToFeatureClass Failed"
arcpy.AddMessage(value)

# Try FeatureClassToFeatureClass to export from SDE to Shapefile
if arcpy.Exists(r"C:\Temp\Townships_From_SDE.shp"): 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(r"C:\Temp\Townships_From_SDE.shp")
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; value = arcpy.FeatureClassToFeatureClass_conversion(in_features=r"Database Connections\GIS.sde\gis.cvr.Basemap\gis.cvr.Townships",out_path=r"C:\Temp",out_name="Townships_From_SDE.shp")
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; value = "FeatureClassToFeatureClass Failed"
arcpy.AddMessage(value)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I run this from Toolbox inside of ArcGIS the output is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Executing: arcpytesting
Start Time: Wed Oct 16 13:12:03 2013
Running script arcpytesting...
Database Connections\GIS.sde Exists
C:\Users\RMcCulley\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\GIS.sde Exists
Database Connections\GIS.sde\gis.cvr.Basemap\gis.cvr.Townships Exists
G:\Parcel GIS Files\Townships.shp Exists
C:\Temp\Townships_From_SHP.shp
C:\Temp\Townships_From_SDE.shp
Completed script arcpytesting...
Succeeded at Wed Oct 16 13:12:04 2013 (Elapsed Time: 1.00 seconds)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Everything works fine!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I run this at the command line using C:\Python27\python.exe arcpytesting.py the output is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Database Connections\GIS.sde Exists
C:\Users\RMcCulley\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\GIS.sde Exists
Database Connections\GIS.sde\gis.cvr.Basemap\gis.cvr.Townships Doesn't Exist
G:\Parcel GIS Files\Townships.shp Exists
C:\Temp\Townships_From_SHP.shp
FeatureClassToFeatureClass Failed
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The feature class inside the SDE database doesn't exist, and the FeatureClassToFeatureClass from the SDE database fails.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The exception is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset Database Connections\GIS.sde\gis.cvr.Basemap\gis.cvr.Townships does not exist or is not supported
Failed to execute (FeatureClassToFeatureClass).
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there something I'm missing? Should this script work outside of ArcGIS?&amp;nbsp; It seems strange that arcpy outside of ArcGIS works fine on shapefiles or file geodatabases (I tested this as well), but not on SDE datasets.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Oct 2013 18:19:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565378#M44260</guid>
      <dc:creator>RobMcCulley</dc:creator>
      <dc:date>2013-10-16T18:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy and SDE outside of ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565379#M44261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried to use real sde connection file location instead of "Database Connections\\"?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The connection files are usually at "C:\Users\username\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Oct 2013 19:15:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565379#M44261</guid>
      <dc:creator>ZachLiu1</dc:creator>
      <dc:date>2013-10-16T19:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy and SDE outside of ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565380#M44262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Have you tried to use real sde connection file location instead of "Database Connections\\"?&lt;BR /&gt;&lt;BR /&gt;The connection files are usually at "C:\Users\username\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog"&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried it with the same result.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Oct 2013 20:56:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565380#M44262</guid>
      <dc:creator>RobMcCulley</dc:creator>
      <dc:date>2013-10-16T20:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy and SDE outside of ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565381#M44263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think I've figured out my problem ... sort of.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At version 10.1 I was using a full SDE installation, and scripts running at the command line connected to the database no problem using the .sde file.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;When we moved to 10.2, we dropped the SDE install (because the SDE application server is being phased out by Esri).&amp;nbsp; Instead we followed the &lt;A href="&amp;lt;/span&amp;gt;&amp;lt;a" target="_blank"&gt;Setting" rel="nofollow" target="_blank"&amp;gt;http://resources.arcgis.com/en/help/main/10.2/index.html#/Setting_up_a_geodatabase_in_PostgreSQL/002p00000001000000/]Setting&lt;/A&gt;&lt;SPAN&gt; up a Geodatabase in PostgreSQL instructions.&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This setup works fine inside of ArcGIS, but I can't connect to it using any other python interpreter than the one in ArcGIS.&amp;nbsp;&amp;nbsp; Is there a way to work with PostgreSQL direct connections from python?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Oct 2013 21:23:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565381#M44263</guid>
      <dc:creator>RobMcCulley</dc:creator>
      <dc:date>2013-10-16T21:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy and SDE outside of ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565382#M44264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If it creates an sde connection file and you can use it in ArcGIS, that should be all arcpy needs to connect to the database. And I may be mistaken, but even using direct connects I believe you need to have SDE installed for your database.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Oct 2013 21:59:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565382#M44264</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-10-16T21:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy and SDE outside of ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565383#M44265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If it creates an sde connection file and you can use it in ArcGIS, that should be all arcpy needs to connect to the database. And I may be mistaken, but even using direct connects I believe you need to have SDE installed for your database.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have the ST_Geometry.dll installed in the lib directory of postgresql.&amp;nbsp; That seems to be all I need to do.&amp;nbsp; I can view, edit, delete, and create features in the geodatabase, and the SDE application is not installed on the server.&amp;nbsp; When I connect to the database it creates an sde connection file, which is the file I'm trying to use in arcpy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What's interesting, when I run the following at the command line:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.CreateDatabaseConnection_management("C:\\Temp","GISTest","POSTGRESQL","&amp;lt;server&amp;gt;","DATABASE_AUTH","&amp;lt;user&amp;gt;","&amp;lt;password&amp;gt;","SAVE_USERNAME","gis")&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;It's successful.&amp;nbsp; An sde connection file is created, and I can browse the geodatabase in ArcCatalog.&amp;nbsp; I still can't access any of the data in the geodatabase outside of ArcGIS though.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Oct 2013 13:43:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565383#M44265</guid>
      <dc:creator>RobMcCulley</dc:creator>
      <dc:date>2013-10-17T13:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy and SDE outside of ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565384#M44266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having the same problem. I'm on 10.1 and PostgreSQL and my code was working last week and now I can't access any of my feature classes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is test code that WORKS in the ArcCatalog immediate windows and not from the command prompt:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;username = &amp;gt;USERNAME&amp;lt;
conn1 = "c:/Users/"+username+"/AppData/Roaming/ESRI/Desktop10.1/ArcCatalog/spatialdb_vectors_arcadmin.sde/"
lyr = conn1 + "vectors.arcadmin.AIRPORTS"

if arcpy.Exists(lyr): 
 print "Feature Class Found!"
else: 
 print "FAILURE :(" &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Strangely, if I run this code with the above variables, it works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if arcpy.Exists(conn1): 
 print "DATABASE FOUND!"
else: 
 print "Failure"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone help?&amp;nbsp; Thanks in advance.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:21:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565384#M44266</guid>
      <dc:creator>EthanGranger</dc:creator>
      <dc:date>2021-12-12T00:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy and SDE outside of ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565385#M44267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any resolution on this?&lt;/P&gt;&lt;P&gt;I am trying to automate the migration of data using geoprocessing tools.&amp;nbsp; So I am starting with an XML Workspace Document that I exported using ArcCatalog.&amp;nbsp; When I try to import this into a new geodatabase, I tried dragging the db connection into the geoprocessing tool (ImportXMLWorkspaceDocument) and it fails saying 'Cannot access local or remote database'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This happens with multple tools, i.e., EnableAttachments_management, Append_management and ImportXMLWorkspaceDocuemnt)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jun 2016 19:38:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565385#M44267</guid>
      <dc:creator>RhondaGregory</dc:creator>
      <dc:date>2016-06-03T19:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy and SDE outside of ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565386#M44268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I figured this one out a long time ago - and forgot to mention the resolution to this problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy requires numpy, but doesn't seem to import it automatically.&amp;nbsp; If I import numpy before importing arcpy, arcpy works perfectly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So short answer - every script you're planning to run at the command line, or in an interpreter, should start with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;import numpy&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;import arcpy&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Dec 2018 18:57:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-and-sde-outside-of-arcgis/m-p/565386#M44268</guid>
      <dc:creator>RobMcCulley</dc:creator>
      <dc:date>2018-12-19T18:57:33Z</dc:date>
    </item>
  </channel>
</rss>

