Is This Content Helpful?
We're glad to know this article was helpful.
Instructions provided describe the steps to specify valid Python syntax for an SDE connection file string. The steps below show how to use ModelBuilder to generate the string automatically.
1. In ArcCatalog, create a new toolbox, and within it, a new model. ModelBuilder opens automatically.
2. In the ModelBuilder window, drag in an ArcToolbox tool that can reference the applicable data source. For example, the 'Make Feature Layer' tool or the 'Copy Raster' tool can be used to reference a vector or raster data source in an enterprise geodatabase.
3. In the model, double-click the applicable tool to open it, and populate the fields using the browse controls, combo boxes, or other assists where available, otherwise by typing.
The SDE connection files are located either in the Windows user profile folder on in the specified folder location, as follows:
• In the Copy Raster example, the Input Raster parameter specifies an SDE connection file that is in the Windows user profile folder. When making a database connection using the Add Database Connection tool in ArcCatalog, the database connection file (.sde) is saved in the Windows user profile folder.
• In the Make Feature Layer example, the Input Features parameter specifies an SDE connection file that is not in the Windows user profile but in a folder 'c:/sdeconnections'.
4. Close the tool dialog, leaving the model open. If the required fields are filled with valid data, the model tools are considered validated.
5. From the Model menu, click Export > To Python Script.
6. Edit the exported Python script in a text editor. Find the string that references the SDE data source, copy it, and paste it to your script where needed. In this example, the local variables 'sde1021_MAP_dem_100x_bilinear' and 'sde1021_MAP_Parcels__2_' are string variables containing a path to a connection (.SDE) file.
If the script is to be used outside of ArcMap or ArcCatalog, please refer to KB41592 for information on formatting the SDE connection file string.