HOW TO

Automate enabling geodatabases

Last Published: October 26, 2021

Summary

GIS managers, DBAs, and administrators sometimes need to automate workflows, such as enabling geodatabases. Instructions provided describe how to do this using a Python script.

Procedure

The Python script below demonstrates how to create a connection file and enable a geodatabase.

Note:
To run the Enable Enterprise Geodatabase geoprocessing tool, you must have ArcGIS Desktop (Desktop Standard or Desktop Advanced), ArcGIS Engine Geodatabase Update, or ArcGIS Server installed on the computer from which you connect to the database and enable geodatabase functionality.

Modify the below parameters according to the environment:

temp = r"C:/temp"
auth_file = "C:/Authorizationfile/aut101/Server_Ent_Adv.ecp"
Connection_File_Name = "Nidhi_oracle2.sde"
database_platform = "ORACLE"
instance = "lclinton2/testoracle"
database = ""
account_authentication = "DATABASE_AUTH"
username = "sde"
password = "sde"
save_user_pass="TRUE"
dba_username = "sys"
dba_password = "manager"

Python script:

import arcpy, os, sys, string
def CreateGeoDB(temp,auth_file, Connection_File_Name,database_platform,instance,database,account_authentication,username,password,save_user_pass,dba_username,dba_password):
 #Create connection file
arcpy.CreateDatabaseConnection_management(temp,Connection_File_Name,database_platform,instance,account_authentication,username,password,"SAVE_USERNAME","","","TRANSACTIONAL","","")

 print "Created sdeconnection"

 arcpy.EnableEnterpriseGeodatabase_management(temp + os.sep + Connection_File_Name, auth_file)

 print "Enabled database"

if __name__ == "__main__":

 temp = r"C:/temp"
 auth_file = "C:/Authorizationfile/aut101/Server_Ent_Adv.ecp"
 Connection_File_Name = "Nidhi_oracle2.sde"
 database_platform = "ORACLE"
 instance = "lclinton2/testoracle"
 database = ""
 account_authentication = "DATABASE_AUTH"
 username = "sde"
 password = "sde"
 save_user_pass="TRUE"
 dba_username = "sys"
 dba_password = "manager"
 CreateGeoDB(temp,auth_file, Connection_File_Name,database_platform,instance,database,account_authentication,username,password,save_user_pass,dba_username,dba_password)

Article ID:000011776

Software:
  • ArcGIS Server

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic