<?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: Problem settings arcpy.env.workspace to SDE connection in separate module on arcgis server in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431033#M33873</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The publishing process should package up the .sde connection file and extract it to the Server directories. &amp;nbsp;The path to the .sde file will also be updated within your script, so it'll be able to use the copied .sde connection to connect to the data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Sep 2016 01:42:01 GMT</pubDate>
    <dc:creator>JonathanQuinn</dc:creator>
    <dc:date>2016-09-29T01:42:01Z</dc:date>
    <item>
      <title>Problem settings arcpy.env.workspace to SDE connection in separate module on arcgis server</title>
      <link>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431027#M33867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have problem defining arcpy.env.workspace in a separate module when publishing the script as a Geoprocessing Service on arcgis server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For instance:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;my main tool script:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;from myModule import myTool&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;workspace = "Database Connections\\GEOP011@demma18.sde"&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;tableName = "DEMMA18.MyTable"&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;myTool.execute(workspace, tableName)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;myModule.myTool:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;import arcpy&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;def execute(workspace, tableName)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = workspace&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; doSomething(tableName)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;def doSomething(tableName)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(tableName, ["OBJECTID"]) as cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(row)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When published to the server, this script will return error : &lt;SPAN class=""&gt;cannot open DEMMA18.MyTable&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;However, if I put the same code in a single .py file it runs on the server without error. Any Idea what is going wrong?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2016 17:00:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431027#M33867</guid>
      <dc:creator>MaximeDemers</dc:creator>
      <dc:date>2016-09-26T17:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problem settings arcpy.env.workspace to SDE connection in separate module on arcgis server</title>
      <link>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431028#M33868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What if you specify the full path, one that Server can access to, instead of using "Database Connections" shortcut?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2016 17:05:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431028#M33868</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-09-26T17:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem settings arcpy.env.workspace to SDE connection in separate module on arcgis server</title>
      <link>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431029#M33869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/community/developers/gis-developers/python?sr=search&amp;amp;searchId=e99ed088-519b-4892-b710-1b91d641fb30&amp;amp;searchIndex=0"&gt;https://community.esri.com/community/developers/gis-developers/python?sr=search&amp;amp;searchId=e99ed088-519b-4892-b710-1b91d641fb30&amp;amp;searchIndex=0&lt;/A&gt;‌, &lt;A href="https://community.esri.com/groups/geodatabase?sr=search&amp;amp;searchId=e50806e2-11de-4c1f-a0a3-8d04cab44c1a&amp;amp;searchIndex=0"&gt;https://community.esri.com/groups/geodatabase?sr=search&amp;amp;searchId=e50806e2-11de-4c1f-a0a3-8d04cab44c1a&amp;amp;searchIndex=0&lt;/A&gt;‌, &lt;A href="https://community.esri.com/community/gis/enterprise-gis/arcgis-for-server?sr=search&amp;amp;searchId=f7fb6cc7-2169-4370-a8d9-a2858fcb83fc&amp;amp;searchIndex=2"&gt;https://community.esri.com/community/gis/enterprise-gis/arcgis-for-server?sr=search&amp;amp;searchId=f7fb6cc7-2169-4370-a8d9-a2858fcb83fc&amp;amp;searchIndex=2&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2016 17:06:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431029#M33869</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-09-26T17:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem settings arcpy.env.workspace to SDE connection in separate module on arcgis server</title>
      <link>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431030#M33870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think it is a good idea. I would like to try, but I dont manage the server myself, so I dont kow the path of the Database Connections folder on the server. I will ask for this information and come back with the result.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2016 17:09:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431030#M33870</guid>
      <dc:creator>MaximeDemers</dc:creator>
      <dc:date>2016-09-26T17:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Problem settings arcpy.env.workspace to SDE connection in separate module on arcgis server</title>
      <link>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431031#M33871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joshua Bixby: but if I put the server path instead, wont I be able to publish the service because it will fails on my desktop?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2016 17:13:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431031#M33871</guid>
      <dc:creator>MaximeDemers</dc:creator>
      <dc:date>2016-09-26T17:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Problem settings arcpy.env.workspace to SDE connection in separate module on arcgis server</title>
      <link>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431032#M33872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joshua Bixby suggestion to use an absolute path to the SDE connection file instead of using the "Database Connection" shortcut was a good idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I copied the desired connection file into a shared server that both my desktop and arcgis server have access. I now use this file to define the arcpy.env.workspace, and it works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2016 17:39:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431032#M33872</guid>
      <dc:creator>MaximeDemers</dc:creator>
      <dc:date>2016-09-26T17:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem settings arcpy.env.workspace to SDE connection in separate module on arcgis server</title>
      <link>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431033#M33873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The publishing process should package up the .sde connection file and extract it to the Server directories. &amp;nbsp;The path to the .sde file will also be updated within your script, so it'll be able to use the copied .sde connection to connect to the data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Sep 2016 01:42:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431033#M33873</guid>
      <dc:creator>JonathanQuinn</dc:creator>
      <dc:date>2016-09-29T01:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problem settings arcpy.env.workspace to SDE connection in separate module on arcgis server</title>
      <link>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431034#M33874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I now use the full path to a .sde file located somewhere that both my desktop and the server have access. That solve the problem as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, there is still something strange that happen. I have many GP Services to publish, and &lt;SPAN class=""&gt;I have to close/reopen ArcMap between every publishing process. If not, I got the &lt;CODE&gt;cannot open table&lt;/CODE&gt; error in the server logs when I call the service through REST. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Any Idea why? All GP Services use the same path to the same .sde file as workspace.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY data-addlink-disabled="false" data-canpost="true" data-cansee="false" data-comments-unavailable="false" data-remaining-comments-count="0"&gt;&lt;TR class=""&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Sep 2016 15:05:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431034#M33874</guid>
      <dc:creator>MaximeDemers</dc:creator>
      <dc:date>2016-09-29T15:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem settings arcpy.env.workspace to SDE connection in separate module on arcgis server</title>
      <link>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431035#M33875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would give Joshua Bixby the credit for answering the question.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2016 20:27:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-settings-arcpy-env-workspace-to-sde/m-p/431035#M33875</guid>
      <dc:creator>MitchHolley1</dc:creator>
      <dc:date>2016-11-30T20:27:43Z</dc:date>
    </item>
  </channel>
</rss>

