<?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 Is it possible for a Python GP tool to use pooled server database connections? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-for-a-python-gp-tool-to-use-pooled/m-p/807182#M2332</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wonder if&amp;nbsp;it is possible for a published Python tool in ArcGIS Server 10.6.1 (not Portal/Enterprise, just a stand-alone Server) to make use of a registered database connection.&amp;nbsp; So, what I mean is, I have an instance of ArcGIS Server 10.6.1, and it has several registered database connections to an SDE on another machine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to publish a Python geoprocessing tool to that ArcGIS Server that can use these "pooled" SDE connections to read or write data, so I do not have to upload a separate SDE connection file for every GP tool every time I re-publish it or change the password.&amp;nbsp; This would be similar to how Java web apps use a single Tomcat database connection, which is more efficient and easier to maintain.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I can't figure out of this is possible or what the syntax would be.&amp;nbsp; Here is a simple example of what I'd like to do in Python.&amp;nbsp; All this script does is open up and list the datasets in an SDE schema:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; sys
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

scriptPath &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;scriptPath&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"read_only_connection.sde"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
ds &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDatasets&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ds&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
  dataset_file &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; open&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;scriptPath&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"datasets.txt"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"w"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; d &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; ds&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    dataset_file&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;write&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;d &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\n"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  dataset_file&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;close&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I copy up &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;read_only_connection.sde&lt;/SPAN&gt; to the script's directory after I publish, it will work.&amp;nbsp; But &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;read_only_connection.sde&lt;/SPAN&gt; is already imported as a registered database on the server called &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;read_only_connection&lt;/SPAN&gt; (no .sde extension).&amp;nbsp; How do I reference it from within Python?&amp;nbsp; Is it even possible?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 09:25:18 GMT</pubDate>
    <dc:creator>ZacharyStauber1</dc:creator>
    <dc:date>2021-12-12T09:25:18Z</dc:date>
    <item>
      <title>Is it possible for a Python GP tool to use pooled server database connections?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-for-a-python-gp-tool-to-use-pooled/m-p/807182#M2332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wonder if&amp;nbsp;it is possible for a published Python tool in ArcGIS Server 10.6.1 (not Portal/Enterprise, just a stand-alone Server) to make use of a registered database connection.&amp;nbsp; So, what I mean is, I have an instance of ArcGIS Server 10.6.1, and it has several registered database connections to an SDE on another machine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to publish a Python geoprocessing tool to that ArcGIS Server that can use these "pooled" SDE connections to read or write data, so I do not have to upload a separate SDE connection file for every GP tool every time I re-publish it or change the password.&amp;nbsp; This would be similar to how Java web apps use a single Tomcat database connection, which is more efficient and easier to maintain.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I can't figure out of this is possible or what the syntax would be.&amp;nbsp; Here is a simple example of what I'd like to do in Python.&amp;nbsp; All this script does is open up and list the datasets in an SDE schema:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; sys
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

scriptPath &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;scriptPath&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"read_only_connection.sde"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
ds &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDatasets&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ds&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
  dataset_file &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; open&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;scriptPath&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"datasets.txt"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"w"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; d &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; ds&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    dataset_file&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;write&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;d &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\n"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  dataset_file&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;close&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I copy up &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;read_only_connection.sde&lt;/SPAN&gt; to the script's directory after I publish, it will work.&amp;nbsp; But &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;read_only_connection.sde&lt;/SPAN&gt; is already imported as a registered database on the server called &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;read_only_connection&lt;/SPAN&gt; (no .sde extension).&amp;nbsp; How do I reference it from within Python?&amp;nbsp; Is it even possible?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:25:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-for-a-python-gp-tool-to-use-pooled/m-p/807182#M2332</guid>
      <dc:creator>ZacharyStauber1</dc:creator>
      <dc:date>2021-12-12T09:25:18Z</dc:date>
    </item>
  </channel>
</rss>

