Actualizar geodatabase (Data Management)

Resumen

Actualiza una geodatabase a la última versión para aprovechar las nuevas funcionalidades disponibles en la última versión de ArcGIS. La entrada válida es una geodatabase de archivos o personal, o un archivo de conexión sde o información de conexión para una geodatabase de ArcSDE.

Debe contar con la versión actual de ArcGIS Desktop (ArcEditor or ArcInfo), ArcGIS Engine Runtime con la extensión Geodatabase Update, o ArcGIS Server Standard o Advanced instalada en el equipo desde el que ejecutará la actualización. Para las geodatabases de ArcSDE, se necesita una conexión directa a la geodatabase para ejecutar la actualización. Los controladores de conexión directa que le permiten conectarse a geodatabases anteriores admitidas se instalan automáticamente con ArcGIS Desktop, ArcGIS Engine y ArcGIS Server.

Uso

Sintaxis

UpgradeGDB_management (input_workspace, input_prerequisite_check, input_upgradegdb_check)
ParámetroExplicaciónTipo de datos
input_workspace

Geodatabase de ArcSDE, personal o de archivos que se actualizará

Workspace
input_prerequisite_check

Especifica si se debe ejecutar la verificación de requisitos previos antes de actualizar la geodatabase

  • NO_PREREQUISITE_CHECKNo se ejecuta la verificación de requisitos previos.
  • PREREQUISITE_CHECKSe ejecuta la verificación de requisitos previos. Esta es la opción predeterminada.
Boolean
input_upgradegdb_check

Especifica si se debe realizar la actualización

  • NO_UPGRADENo se realiza la actualización.
  • UPGRADESe realiza la actualización. Esta es la opción predeterminada.
Boolean

Ejemplo de código

Ejemplo 1 de UpgradeGeodatabase (ventana de Python)

La siguiente secuencia de comandos de la ventana de Python muestra cómo utilizar la función UpgradeGDB en el modo inmediato para actualizar una geodatabase de archivos.

import arcpy Output_Workspace = "C:\\temp\\Default.gdb" Default_gdb = "C:\\temp\\Default.gdb" arcpy.UpgradeGDB_management(Default_gdb, "PREREQUISITE_CHECK", "UPGRADE")
Ejemplo 2 de UpgradeGeodatabase (secuencia de comandos independiente para geodatabase de archivos)

La siguiente secuencia de comandos de Python independiente muestra cómo utilizar la función UpgradeGDB en una secuencia de comandos de Python para actualizar una geodatabase de archivos:

  # Description: upgrade a geodatabase   # Import arcpy module import arcpy  # Local variables: Output_Workspace = "C:\\temp\\Default.gdb" Default_gdb = "C:\\temp\\Default.gdb"  # Process: Upgrade Geodatabase arcpy.UpgradeGDB_management(Default_gdb, "PREREQUISITE_CHECK", "UPGRADE")
Ejemplo 3 de UpgradeGeodatabase (secuencia de comandos independiente mediante un archivo de conexión .sde)

La siguiente secuencia de comandos de Python independiente muestra cómo utilizar la función UpgradeGDB en una secuencia de comandos de Python para actualizar una geodatabase de ArcSDE mediante un archivo de conexión .sde.

# Description: upgrade a geodatabase  # Import arcpy module import arcpy  # Local variables: Output_Workspace = "C:\\Documents and Settings\<user>\Application Data\ESRI\ArcCatalog\Connection to gdb.sde" Default_gdb = "C:\\Documents and Settings\<user>\Application Data\ESRI\ArcCatalog\Connection to gdb.sde"  # Process: Upgrade Geodatabase arcpy.UpgradeGDB_management(Default_gdb, "PREREQUISITE_CHECK", "UPGRADE")
Ejemplo 4 de UpgradeGeodatabase (secuencia de comandos independiente para ArcSDE en Oracle)

La siguiente secuencia de comandos de Python independiente muestra cómo utilizar la función UpgradeGDB en una secuencia de comandos de Python para actualizar una geodatabase de ArcSDE en Oracle:

"""
Name: upgrade_gdb.py
Description: Provide connection information to an Enterprise geodatabase 
and upgrade the geodatabase
Type upgrade_gdb.py -h or upgrade_gdb.py --help for usage
"""

# Import system modules
import arcpy, os, optparse, sys


# Define usage and version
parser = optparse.OptionParser(usage = "usage: %prog [Options]", version="%prog 1.0; valid for 10.0 and 10.1 release")

#Define help and options
parser.add_option ("-s", dest="Server", type="string", default="", help="RDBMS server name")
parser.add_option ("-i", dest="Service", type="string", default="", help="Use direct connection syntax")
parser.add_option ("--auth", dest="account_authentication", type ="choice", choices=['DATABASE_AUTH', 'OPERATING_SYSTEM_AUTH'], default='DATABASE_AUTH', help="Authentication type options (case-sensitive):  DATABASE_AUTH, OPERATING_SYSTEM_AUTH.  Default=DATABASE_AUTH")
parser.add_option ("-u", dest="User", type="string", default="", help="Geodatabase administrator user name")
parser.add_option ("-p", dest="Password", type="string", default="", help="Geodatabase administrator password")
parser.add_option ("-v", dest="Version", type="string", help="ArcSDE version name")
parser.add_option ("--upgrade", dest="Upgrade", type="choice", choices=['TRUE', 'FALSE'], default="FALSE", help="Upgrade Options (case-sensitive):  TRUE=Perform Pre-requisite check and upgrade geodatabase, FALSE=Perform Pre-requisite check only.  Default=FALSE")                   
parser.add_option ("-d", dest="Database", type="string", default="none", help="Database name:  Not required for Oracle")


# Check if value entered for option
try:
	(options, args) = parser.parse_args()

	
#Check if no system arguments (options) entered
	if len(sys.argv) == 1:
		print "%s: error: %s\n" % (sys.argv[0], "No command options given")
		parser.print_help()
		sys.exit(3)
	

	#Usage parameters for spatial database connection to upgrade
	server = options.Server
	service = options.Service	
	account_authentication = options.account_authentication.upper()
	username = options.User.lower() 
	password = options.Password	
	version = options.Version.upper()
	do_upgrade = options.Upgrade
	database = options.Database.lower()
	
	
	# Get the current product license
	product_license=arcpy.ProductInfo()
	
	
	# Checks required license level to upgrade
	if product_license.upper() == "ARCVIEW" or product_license.upper() == 'ENGINE':
		print "\n" + product_license + " license found!" + "  Enterprise geodatabase upgrade requires an ArcEditor, ArcInfo, ArcGIS Engine Geodatabase Update, or ArcGIS Server license."
		sys.exit("Re-authorize ArcGIS before upgrading.")
	else:
		print "\n" + product_license + " license available!  Continuing to upgrade..."
		arcpy.AddMessage("+++++++++")
	
	
	# Check if direct connection
	if service.find(":") <> -1:  #This is direct connect
		ServiceConnFileName = service.replace(":", "")
		ServiceConnFileName = ServiceConnFileName.replace(";", "")
		ServiceConnFileName = ServiceConnFileName.replace("=", "")
		ServiceConnFileName = ServiceConnFileName.replace("/", "")
		ServiceConnFileName = ServiceConnFileName.replace("\\", "")
	else:
		arcpy.AddMessage("\n+++++++++")
		arcpy.AddMessage("Exiting!!")
		arcpy.AddMessage("+++++++++")
		sys.exit("\nSyntax for a direct connection in the Service parameter is required for geodatabase upgrade.")
	
	
	# Local variables
	Conn_File_NameT = server + "_" + ServiceConnFileName + "_" + database + "_" + username    
	
	if os.environ.get("TEMP") == None:
		temp = "c:\\temp"	
	else:
		temp = os.environ.get("TEMP")
	
	if os.environ.get("TMP") == None:
		temp = "/usr/tmp"		
	else:
		temp = os.environ.get("TMP")  
	
	Connection_File_Name = temp + os.sep + Conn_File_NameT + ".sde"
	
	
	# Check for the .sde file and delete it if present
	arcpy.env.overwriteOutput=True
	
	
	# Variables defined within the script; other variable options commented out at the end of the line
	saveUserInfo = "SAVE_USERNAME" #DO_NOT_SAVE_USERNAME
	saveVersionInfo = "SAVE_VERSION" #DO_NOT_SAVE_VERSION
	
	
	print "\nCreating ArcSDE Connection File...\n"
	# Process: Create ArcSDE Connection File...
	# Usage: out_folder_path, out_name, server, service, database, account_authentication, username, password, save_username_password, version,   save_version_info
	arcpy.CreateArcSDEConnectionFile_management(temp, Conn_File_NameT, server, service, database, account_authentication, username, password, saveUserInfo, version, saveVersionInfo)
	for i in range(arcpy.GetMessageCount()):
		if "000565" in arcpy.GetMessage(i):   #Check if database connection was successful
			arcpy.AddReturnMessage(i)
			arcpy.AddMessage("\n+++++++++")
			arcpy.AddMessage("Exiting!!")
			arcpy.AddMessage("+++++++++\n")
			sys.exit(3)            
		else:
			arcpy.AddReturnMessage(i)
			arcpy.AddMessage("+++++++++\n")
	
	
	# Process: Upgrade geodatabase...
	try:
		if do_upgrade.lower() == "true":
			print "Upgrading Geodatabase...\n"
			arcpy.UpgradeGDB_management(Connection_File_Name, "PREREQUISITE_CHECK", "UPGRADE")
			for i in range(arcpy.GetMessageCount()):
				arcpy.AddReturnMessage(i)
			arcpy.AddMessage("+++++++++\n")
	
		else:
			print "Running Pre-Requisite Check...\n"
			arcpy.UpgradeGDB_management(Connection_File_Name, "PREREQUISITE_CHECK", "NO_UPGRADE")
			for i in range(arcpy.GetMessageCount()):
				arcpy.AddReturnMessage(i)
			arcpy.AddMessage("+++++++++\n")
	
	except:
		for i in range(arcpy.GetMessageCount()):
			arcpy.AddReturnMessage(i)
			
#Check if no value entered for option	
except SystemExit as e:
	if e.code == 2:
		parser.usage = ""
		print "\n"
		parser.print_help()   
		parser.exit(2)
Ejemplo 5 de UpgradeGeodatabase (secuencia de comandos independiente para ArcSDE en bases de datos que no sean de Oracle)

La siguiente secuencia de comandos de Python independiente muestra cómo utilizar la función UpgradeGDB en una secuencia de comandos de Python para actualizar una geodatabase de ArcSDE en IBM DB2, Informix, Microsoft SQL Server o PostgreSQL:

"""
Name: upgrade_gdb.py
Description: Provide connection information to an Enterprise geodatabase 
and upgrade the geodatabase
Type upgrade_gdb.py -h or upgrade_gdb.py --help for usage
"""

# Import system modules
import arcpy, os, optparse, sys


# Define usage and version
parser = optparse.OptionParser(usage = "usage: %prog [Options]", version="%prog 1.0; valid for 10.0 and 10.1 release")

#Define help and options
parser.add_option ("-s", dest="Server", type="string", default="", help="RDBMS server name")
parser.add_option ("-i", dest="Service", type="string", default="", help="Use direct connection syntax")
parser.add_option ("--auth", dest="account_authentication", type ="choice", choices=['DATABASE_AUTH', 'OPERATING_SYSTEM_AUTH'], default='DATABASE_AUTH', help="Authentication type options (case-sensitive):  DATABASE_AUTH, OPERATING_SYSTEM_AUTH.  Default=DATABASE_AUTH")
parser.add_option ("-u", dest="User", type="string", default="", help="Geodatabase administrator user name")
parser.add_option ("-p", dest="Password", type="string", default="", help="Geodatabase administrator password")
parser.add_option ("-v", dest="Version", type="string", help="ArcSDE version name")
parser.add_option ("--upgrade", dest="Upgrade", type="choice", choices=['TRUE', 'FALSE'], default="FALSE", help="Upgrade Options (case-sensitive):  TRUE=Perform Pre-requisite check and upgrade geodatabase, FALSE=Perform Pre-requisite check only.  Default=FALSE")                   
parser.add_option ("-d", dest="Database", type="string", default="none", help="Database name:  Not required for Oracle")


# Check if value entered for option
try:
	(options, args) = parser.parse_args()

	
#Check if no system arguments (options) entered
	if len(sys.argv) == 1:
		print "%s: error: %s\n" % (sys.argv[0], "No command options given")
		parser.print_help()
		sys.exit(3)
	

	#Usage parameters for spatial database connection to upgrade
	server = options.Server
	service = options.Service	
	account_authentication = options.account_authentication.upper()
	username = options.User.lower() 
	password = options.Password	
	version = options.Version.upper()
	do_upgrade = options.Upgrade
	database = options.Database.lower()
	
	
	# Get the current product license
	product_license=arcpy.ProductInfo()
	
	
	# Checks required license level to upgrade
	if product_license.upper() == "ARCVIEW" or product_license.upper() == 'ENGINE':
		print "\n" + product_license + " license found!" + "  Enterprise geodatabase upgrade requires an ArcEditor, ArcInfo, ArcGIS Engine Geodatabase Update, or ArcGIS Server license."
		sys.exit("Re-authorize ArcGIS before upgrading.")
	else:
		print "\n" + product_license + " license available!  Continuing to upgrade..."
		arcpy.AddMessage("+++++++++")
	
	
	# Check if direct connection
	if service.find(":") <> -1:  #This is direct connect
		ServiceConnFileName = service.replace(":", "")
		ServiceConnFileName = ServiceConnFileName.replace(";", "")
		ServiceConnFileName = ServiceConnFileName.replace("=", "")
		ServiceConnFileName = ServiceConnFileName.replace("/", "")
		ServiceConnFileName = ServiceConnFileName.replace("\\", "")
	else:
		arcpy.AddMessage("\n+++++++++")
		arcpy.AddMessage("Exiting!!")
		arcpy.AddMessage("+++++++++")
		sys.exit("\nSyntax for a direct connection in the Service parameter is required for geodatabase upgrade.")
	
	
	# Local variables
	Conn_File_NameT = server + "_" + ServiceConnFileName + "_" + database + "_" + username    
	
	if os.environ.get("TEMP") == None:
		temp = "c:\\temp"	
	else:
		temp = os.environ.get("TEMP")
	
	if os.environ.get("TMP") == None:
		temp = "/usr/tmp"		
	else:
		temp = os.environ.get("TMP")  
	
	Connection_File_Name = temp + os.sep + Conn_File_NameT + ".sde"
	
	
	# Check for the .sde file and delete it if present
	arcpy.env.overwriteOutput=True
	
	
	# Variables defined within the script; other variable options commented out at the end of the line
	saveUserInfo = "SAVE_USERNAME" #DO_NOT_SAVE_USERNAME
	saveVersionInfo = "SAVE_VERSION" #DO_NOT_SAVE_VERSION
	
	
	print "\nCreating ArcSDE Connection File...\n"
	# Process: Create ArcSDE Connection File...
	# Usage: out_folder_path, out_name, server, service, database, account_authentication, username, password, save_username_password, version,   save_version_info
	arcpy.CreateArcSDEConnectionFile_management(temp, Conn_File_NameT, server, service, database, account_authentication, username, password, saveUserInfo, version, saveVersionInfo)
	for i in range(arcpy.GetMessageCount()):
		if "000565" in arcpy.GetMessage(i):   #Check if database connection was successful
			arcpy.AddReturnMessage(i)
			arcpy.AddMessage("\n+++++++++")
			arcpy.AddMessage("Exiting!!")
			arcpy.AddMessage("+++++++++\n")
			sys.exit(3)            
		else:
			arcpy.AddReturnMessage(i)
			arcpy.AddMessage("+++++++++\n")
	
	
	# Process: Upgrade geodatabase...
	try:
		if do_upgrade.lower() == "true":
			print "Upgrading Geodatabase...\n"
			arcpy.UpgradeGDB_management(Connection_File_Name, "PREREQUISITE_CHECK", "UPGRADE")
			for i in range(arcpy.GetMessageCount()):
				arcpy.AddReturnMessage(i)
			arcpy.AddMessage("+++++++++\n")
	
		else:
			print "Running Pre-Requisite Check...\n"
			arcpy.UpgradeGDB_management(Connection_File_Name, "PREREQUISITE_CHECK", "NO_UPGRADE")
			for i in range(arcpy.GetMessageCount()):
				arcpy.AddReturnMessage(i)
			arcpy.AddMessage("+++++++++\n")
	
	except:
		for i in range(arcpy.GetMessageCount()):
			arcpy.AddReturnMessage(i)
			
#Check if no value entered for option	
except SystemExit as e:
	if e.code == 2:
		parser.usage = ""
		print "\n"
		parser.print_help()   
		parser.exit(2)

Entornos

Esta herramienta no utiliza ningún entorno de geoprocesamiento

Información de licencia

ArcView: Requiere Licencia de ArcEditor o ArcInfo para actualizar las geodatabases de ArcSDE. Para las geodatabases personales y de archivos sólo se necesita una licencia de ArcView.
ArcEditor: Sí
ArcInfo: Sí

3/6/2012