<?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 error : Object: Could not open SDE workspace in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296760#M22923</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We just use the sde file directly.&amp;nbsp; So just c:\temp\db.sde for example.&amp;nbsp; Just make a connection then copy and paste it to any directory.&amp;nbsp; We have a Connections directory with links to all our dbs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Jun 2016 16:21:21 GMT</pubDate>
    <dc:creator>DougBrowning</dc:creator>
    <dc:date>2016-06-07T16:21:21Z</dc:date>
    <item>
      <title>Arcpy error : Object: Could not open SDE workspace</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296758#M22921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi at all,&lt;/P&gt;&lt;P&gt;i have develop a python script that execute a query to table into sde connection (DB Oracle).&lt;/P&gt;&lt;P&gt;This my code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env

env.workspace = ("Database Connections/TEST.sde")
sdeConn = arcpy.ArcSDESQLExecute("Database Connections/TEST.sde")
value = 'V'


sql = "select * from TEST.CATEGORIES WHERE TIP_SER = " + value
print(sql)
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; sdeReturn = sdeConn.execute(sql)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print('ok')
except Exception, ErrorDesc:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print ErrorDesc
&amp;nbsp;&amp;nbsp;&amp;nbsp; sdeReturn = False

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when i run i recive this error: RuntimeError: Object: Could not open SDE workspace&lt;/P&gt;&lt;P&gt;The sde connection works fine into ArcMap and also i have try other simple connection by arcpy for print a list table and works fine.&lt;/P&gt;&lt;P&gt;So why this error?&lt;/P&gt;&lt;P&gt;Any help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:14:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296758#M22921</guid>
      <dc:creator>DEVAPP</dc:creator>
      <dc:date>2021-12-11T14:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy error : Object: Could not open SDE workspace</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296759#M22922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code is quite a bit different than the examples in the help topic &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/arcsdesqlexecute.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/arcsdesqlexecute.htm"&gt;ArcSDESQLExecute—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;P&gt;I would at least put your attempt at a connection within the try-except block and check the parameters, some of them don't appear to be optional.&amp;nbsp; Script functionality within arcmap is not the same as that outside that environment, there is nothing assumed or available, and anything that needs to be specified must be.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jun 2016 14:47:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296759#M22922</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-07T14:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy error : Object: Could not open SDE workspace</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296760#M22923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We just use the sde file directly.&amp;nbsp; So just c:\temp\db.sde for example.&amp;nbsp; Just make a connection then copy and paste it to any directory.&amp;nbsp; We have a Connections directory with links to all our dbs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jun 2016 16:21:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296760#M22923</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2016-06-07T16:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy error : Object: Could not open SDE workspace</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296761#M22924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Doug,&lt;/P&gt;&lt;P&gt;i have pasted the sde connection in other folder and after i have tried the script in this way but the result is always the same&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jun 2016 07:33:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296761#M22924</guid>
      <dc:creator>DEVAPP</dc:creator>
      <dc:date>2016-06-08T07:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy error : Object: Could not open SDE workspace</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296762#M22925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;thanks for your response.&lt;/P&gt;&lt;P&gt;I have seen the example that you have attached and as Syntax require some parameters not optional, but the .sde contain itself all the parameter request:&lt;/P&gt;&lt;P&gt;server, port, istance, use and psw etc&lt;/P&gt;&lt;P&gt;Example if i set sde connection as workspace for a list table the script works so i suppose that the connection is open:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = (&lt;SPAN class="string"&gt;"Database Connections/TEST.sde")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;tables = arcpy.ListTables()&lt;/P&gt;&lt;P&gt;for t in tables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(t)&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jun 2016 08:04:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296762#M22925</guid>
      <dc:creator>DEVAPP</dc:creator>
      <dc:date>2016-06-08T08:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy error : Object: Could not open SDE workspace</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296763#M22926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see two things as possibly being a problem.&lt;/P&gt;&lt;P&gt;1. value = 'V'&lt;/P&gt;&lt;P&gt;The value in the sql syntax will need to be in quotes so change this to:&lt;/P&gt;&lt;P&gt;value = &lt;STRONG&gt;"'V'" &lt;/STRONG&gt;(to make more clear it's... "&amp;nbsp; '&amp;nbsp; V&amp;nbsp; '&amp;nbsp; ")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. If TEST.CATEGORIES is a feature class with a shape column "select * from..." will not work. Change this to:&lt;/P&gt;&lt;P&gt;sql = "select &lt;STRONG&gt;fld1, fld2, fld3&lt;/STRONG&gt; from TEST.CATEGORIES WHERE TIP_SER = " + value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if changing these helps.&lt;/P&gt;&lt;P&gt;Thanks. Ken&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 19:43:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296763#M22926</guid>
      <dc:creator>KenHartling</dc:creator>
      <dc:date>2016-06-09T19:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy error : Object: Could not open SDE workspace</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296764#M22927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ken,&lt;/P&gt;&lt;P&gt;the query with value = " 'V' " is ok.&lt;/P&gt;&lt;P&gt;Now the sdeConn = arcpy.ArcSDESQLExecute(&lt;SPAN class="string"&gt;"Database Connections/TEST.sde") works fine also without the query.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;I have copied and pasted my code into other ArcGIS enviromets and works fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;I suppose that on my machine after istall of python 3 there is something to wrong.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;Thanks to all &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jun 2016 10:26:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/296764#M22927</guid>
      <dc:creator>DEVAPP</dc:creator>
      <dc:date>2016-06-10T10:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy error : Object: Could not open SDE workspace</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/1084530#M61905</link>
      <description>&lt;P&gt;I'm having the same issue for just trying to run one lame arcpy.da.ListDatabaseSequences()&lt;/P&gt;&lt;P&gt;It works on a normal file gdb, but I can't do it on our sde database. ArcGIS Pro 2.7&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 18:01:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-error-object-could-not-open-sde-workspace/m-p/1084530#M61905</guid>
      <dc:creator>IngridMans</dc:creator>
      <dc:date>2021-07-30T18:01:57Z</dc:date>
    </item>
  </channel>
</rss>

