<?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 there a easy way to Export a MXD with a lot of SDE connections? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/is-there-a-easy-way-to-export-a-mxd-with-a-lot-of/m-p/740703#M57276</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a simple script that exports a map to a JPEG. Here is the meat of it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
print "generating ouput of " + mxdPath
mxd = arcpy.mapping.MapDocument(mxdPath)

arcpy.mapping.ExportToJPEG(mxd, outputPath, 'PAGE_LAYOUT',1024,1024)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pretty easy. Problem is there is a ton of SDE Connections, that in turn throw a "Spatial Connection Dialog" that stalls the script. I found a blog or a forum post that said if I use the "CreateArcSDEConnectionFile_management" GP to create the .sde files before I tried exporting the jpeg, I wouldn't get the Spatial Connection Dialog. Seemed to work ok but the problem is every time I run this script i need to create some 10 .sde connection files for the different SDE servers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
# create temporary connection files in memory
print "create ArcSDE Connection files"
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'created'
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('create connections')
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection1", "Server1", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection2", "Server2", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection3", "Server3", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection4", "Server4", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection5", "Server5", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection6", "Server6", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection7", "Server7", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection8", "Server8", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection9", "Server9", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")



except Exception as e:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print e.message

&amp;nbsp;&amp;nbsp;&amp;nbsp; # If using this code within a script tool, AddError can be used to return messages
&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp; back to a script tool.&amp;nbsp; If not, AddError will have no effect.
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(e.message)

print "generating ouput of " + mxdPath
mxd = arcpy.mapping.MapDocument(mxdPath)

arcpy.mapping.ExportToJPEG(mxd, outputPath, 'PAGE_LAYOUT',1024,1024)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This works OK, but is slow when I run through 100 maps as I have to run them one at a time. Is there a better way to do this? Is there a way for me to create these .sde connection files, and in the script somehow reference them?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 May 2012 16:42:43 GMT</pubDate>
    <dc:creator>ShaneHelm</dc:creator>
    <dc:date>2012-05-15T16:42:43Z</dc:date>
    <item>
      <title>Is there a easy way to Export a MXD with a lot of SDE connections?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-easy-way-to-export-a-mxd-with-a-lot-of/m-p/740703#M57276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a simple script that exports a map to a JPEG. Here is the meat of it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
print "generating ouput of " + mxdPath
mxd = arcpy.mapping.MapDocument(mxdPath)

arcpy.mapping.ExportToJPEG(mxd, outputPath, 'PAGE_LAYOUT',1024,1024)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pretty easy. Problem is there is a ton of SDE Connections, that in turn throw a "Spatial Connection Dialog" that stalls the script. I found a blog or a forum post that said if I use the "CreateArcSDEConnectionFile_management" GP to create the .sde files before I tried exporting the jpeg, I wouldn't get the Spatial Connection Dialog. Seemed to work ok but the problem is every time I run this script i need to create some 10 .sde connection files for the different SDE servers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
# create temporary connection files in memory
print "create ArcSDE Connection files"
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'created'
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('create connections')
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection1", "Server1", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection2", "Server2", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection3", "Server3", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection4", "Server4", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection5", "Server5", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection6", "Server6", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection7", "Server7", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection8", "Server8", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateArcSDEConnectionFile_management( sdeConnectionFolder, "Connection9", "Server9", "5161", "", "DATABASE_AUTH", "[USERNAME]", "[password]", "SAVE_USERNAME", "SDE.DEFAULT", "SAVE_VERSION")



except Exception as e:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print e.message

&amp;nbsp;&amp;nbsp;&amp;nbsp; # If using this code within a script tool, AddError can be used to return messages
&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp; back to a script tool.&amp;nbsp; If not, AddError will have no effect.
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(e.message)

print "generating ouput of " + mxdPath
mxd = arcpy.mapping.MapDocument(mxdPath)

arcpy.mapping.ExportToJPEG(mxd, outputPath, 'PAGE_LAYOUT',1024,1024)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This works OK, but is slow when I run through 100 maps as I have to run them one at a time. Is there a better way to do this? Is there a way for me to create these .sde connection files, and in the script somehow reference them?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 May 2012 16:42:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-easy-way-to-export-a-mxd-with-a-lot-of/m-p/740703#M57276</guid>
      <dc:creator>ShaneHelm</dc:creator>
      <dc:date>2012-05-15T16:42:43Z</dc:date>
    </item>
  </channel>
</rss>

