English

How To: Automate enabling geodatabases

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:
The "Enable Enterprise Geodatabase" tool is available in ArcGIS for Desktop Standard and Advanced license levels only.

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:

Code:
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)

Related Information