<?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 Centralizing database connection strings and publishing GP Services in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282301#M21783</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have created a python script that contains all of my database connection strings and when I'm working locally, I can just import those strings like you would any regular module and use them. When I publish a geoprocessing service though, I can't figure out how to use an imported module like this because those connection strings won't be made into g_ESRI variables. My goal is to have one central place to update all my connection string paths if they change in the future, rather than going into 50 different scripts and changing each one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what my database connection python file (DatabaseConnections.py) looks like:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;hb_db_con &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\Users\xxx\AppData\Roaming\ESRI\Desktop10.7\ArcCatalog\FocalAreas_HabitatWriter.sde'&lt;/SPAN&gt;
fa_db_con &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\Users\xxx\AppData\Roaming\ESRI\Desktop10.7\ArcCatalog\HbMon_HabitatWriter.sde'&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#So on and so forth&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The top of the geoprocessing service I publish imports those connections like so:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; DatabaseConnections &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; hb_db_con&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fa_db_con

fc1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; hb_db_con &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\blah.DBO.blahblah"&lt;/SPAN&gt;
fc2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fa_db_con &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\blah2.DBO.blahblahblah"&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have copied DatabaseConnections.py to the server's python library so it can find the connection strings, but obviously it doesn't convert them to where the server should find the data and instead just takes the hard-copied connection string and goes searching, coming up with nothing. Is there a way to centralize database connection strings in your code and still make it publishable?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 13:40:58 GMT</pubDate>
    <dc:creator>MKF62</dc:creator>
    <dc:date>2021-12-11T13:40:58Z</dc:date>
    <item>
      <title>Centralizing database connection strings and publishing GP Services</title>
      <link>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282301#M21783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have created a python script that contains all of my database connection strings and when I'm working locally, I can just import those strings like you would any regular module and use them. When I publish a geoprocessing service though, I can't figure out how to use an imported module like this because those connection strings won't be made into g_ESRI variables. My goal is to have one central place to update all my connection string paths if they change in the future, rather than going into 50 different scripts and changing each one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what my database connection python file (DatabaseConnections.py) looks like:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;hb_db_con &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\Users\xxx\AppData\Roaming\ESRI\Desktop10.7\ArcCatalog\FocalAreas_HabitatWriter.sde'&lt;/SPAN&gt;
fa_db_con &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\Users\xxx\AppData\Roaming\ESRI\Desktop10.7\ArcCatalog\HbMon_HabitatWriter.sde'&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#So on and so forth&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The top of the geoprocessing service I publish imports those connections like so:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; DatabaseConnections &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; hb_db_con&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fa_db_con

fc1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; hb_db_con &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\blah.DBO.blahblah"&lt;/SPAN&gt;
fc2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fa_db_con &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\blah2.DBO.blahblahblah"&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have copied DatabaseConnections.py to the server's python library so it can find the connection strings, but obviously it doesn't convert them to where the server should find the data and instead just takes the hard-copied connection string and goes searching, coming up with nothing. Is there a way to centralize database connection strings in your code and still make it publishable?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:40:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282301#M21783</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2021-12-11T13:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Centralizing database connection strings and publishing GP Services</title>
      <link>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282302#M21784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What's the authentication on your DBs?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Jun 2020 11:04:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282302#M21784</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-06-06T11:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Centralizing database connection strings and publishing GP Services</title>
      <link>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282303#M21785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Database authentication is used for geoprocessing services.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jun 2020 18:23:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282303#M21785</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2020-06-17T18:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Centralizing database connection strings and publishing GP Services</title>
      <link>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282304#M21786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have these various DB connections been registered with your Server's Data Store?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jun 2020 18:28:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282304#M21786</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2020-06-17T18:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Centralizing database connection strings and publishing GP Services</title>
      <link>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282305#M21787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you're talking about Data Store proper (the thing that comes with ArcGIS Enterprise), we&amp;nbsp;don't have that or portal installed. Just Server. But all the databases are registered with the server.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/497063_Capture.JPG" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jun 2020 12:31:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282305#M21787</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2020-06-18T12:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Centralizing database connection strings and publishing GP Services</title>
      <link>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282306#M21788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I see. What if you put your SDE connection files in a shared network location and have your script point to those? The location would have to be made available to the ArcGIS service account. Not sure if you used a domain or local machine account for your server setup. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jun 2020 12:50:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282306#M21788</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2020-06-18T12:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Centralizing database connection strings and publishing GP Services</title>
      <link>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282307#M21789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's a good idea, I can give that a shot. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jun 2020 13:22:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/centralizing-database-connection-strings-and/m-p/282307#M21789</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2020-06-18T13:22:41Z</dc:date>
    </item>
  </channel>
</rss>

