A gp tool needs to be released today, but some logic needs to be processed. So I plan to write a py script and put it in the model.
I have studied the py library of arcpy ArcGIS.
First, open the IDE of Py
Introduce arcpy Library
Test the call permit settings to allow access to the spatial database.
Note that SDE. Sde is the service name you configured in catalog.
Py is case sensitive.
The following describes how to set up the arcpy environment env for a spatial database.
Then perform operations through several interface methods
The main point is to directly write the absolute path to the local file path when setting the workspace.
If you want to connect to SDE, you must specify the location of the. Sde file.
(4) SDE is configured in catalog, so it points to the SDE under the database connections path. the SDE file database connections is the default storage of ArcGIS. you can also create a path for the SDE connection file. SDE File
Here, I picked up a section of my brother-in-law.CodeTransfer door http://www.cnblogs.com/mingkof/archive/2013/02/04/2891525.html
#. Sde file path
Sdefilepath_sde = sdefilepath +"\\"+ Sdefilename +". Sde"
IfOS. Path. isfile (sdefilepath_sde ):
OS. Remove (sdefilepath_sde)
Print 'Deleting an existing SDE file ends.'
# Create an SDE File
Arcpy. createarcsdeconnectionfile_management (sdefilepath, sdefilename, sdeserver, sdeservice, "" , " Database_auth " ,
Sdeusername, sdepassword, " Save_username " , " SDE. Default " , " Save_version " )
Print ' SDE File Created '
Figure 4
Come here first