Summary
Creates a file that ArcGIS uses to connect to a database or an enterprise geodatabase.
Usage
After valid connection information is entered to establish a connection in the tool dialog box, the tool will connect to the database to determine if it contains the geodatabase schema.
- For databases, all the parameters in the Geodatabase Connection Properties section of the tool dialog box are ignored.
- For geodatabases, the tool automatically populates the Geodatabase Connection Properties section. The Schema parameter is set with the sde schema (for Oracle user schema geodatabases only), the default Version Type for the geodatabase, and the Default version.
Connections from ArcGIS to Altibase and Netezza are no longer supported.
Syntax
CreateDatabaseConnection(out_folder_path, out_name, database_platform, instance, {account_authentication}, {username}, {password}, {save_user_pass}, {database}, {schema}, {version_type}, {version}, {date})
Parameter | Explanation | Data Type |
out_folder_path | The folder path where the database connection file (.sde file) will be stored. | Folder |
out_name | The name of the database connection file. The output file will have the extension .sde. | String |
database_platform | Specifies the database management system platform to which you will be connecting. The following are valid options:
| String |
instance | The database server or instance to which you will connect. The value you specify for the database_platform parameter indicates the type of database to which you want to connect. The information you provide for the instance parameter varies, depending on the database platform you specified. See below for further information on what to provide for each database platform.
| String |
account_authentication (Optional) | Specifies the type of authentication that will be used.
| Boolean |
username (Optional) | The database user name that will be used when using database authentication. | String |
password (Optional) | The database user password that will be used when using database authentication. | Encrypted String |
save_user_pass (Optional) | Specifies whether the user name and password will be saved.
| Boolean |
database (Optional) | The name of the database to which you will connect. This parameter only applies to PostgreSQL and SQL Server platforms. | String |
schema (Optional) | The user schema geodatabase to which you will connect. This option only applies to Oracle databases that contain at least one user–schema geodatabase. The default value for this parameter is to use the sde schema (master) geodatabase. | String |
version_type (Optional) | Specifies the type of version to which you will connect.
Note:If TRANSACTIONAL or HISTORICAL is used, the date parameter will be ignored. If HISTORICAL is used and a name is not provided in the version parameter, the default transactional version will be used. If POINT_IN_TIME is used and a date is not provided in the date parameter, the default transactional version will be used. | String |
version (Optional) | The geodatabase transactional version or historical marker to connect to. The default option uses the default transactional version. If you choose a branch version type, the connection is always to the default branch version. | String |
date (Optional) | The value representing the date and time that will be used to connect to the database when working with archive-enabled data. Dates can be entered in the following formats:
Note:
| Date |
Derived Output
Name | Explanation | Data Type |
out_workspace | The output database connection file (.sde file). | workspace |
Code sample
The following Python window script demonstrates how to use the CreateDatabaseConnection tool in immediate mode.
import arcpy
arcpy.CreateDatabaseConnection_management("C:\\MyProject",
"utah.sde",
"SQL_SERVER",
"utah",
"DATABASE_AUTH",
"gdb",
"gdb",
"SAVE_USERNAME",
"garfield",
"#",
"TRANSACTIONAL",
"sde.DEFAULT")
The following stand-alone script demonstrates how to use the CreateDatabaseConnection tool.
# Name: CreateDatabaseConnection2.py
# Description: Connects to a database using Easy Connect string
# and operating system authentication.
# Import system modules
import arcpy
# Run the tool
arcpy.CreateDatabaseConnection_management("C:\\MyProject",
"zion.sde",
"ORACLE",
"zionserver/ORCL",
"OPERATING_SYSTEM_AUTH")
The following Python window script demonstrates how to use the CreateDatabaseConnection tool to connect to an historical marker.
# Name: CreateDatabaseConnection3.py
# Description: Connects to a geodatabase historical marker using a
# cataloged DB2 database and database authentication.
# Import system modules
import arcpy
# Run the tool
arcpy.CreateDatabaseConnection_management("C:\\MyProject",
"history.sde",
"DB2",
"DB2_DS",
"DATABASE_AUTH",
"butch",
"sundance",
"SAVE_USERNAME",
"#",
"#",
"HISTORICAL",
"June 9, 2010",
"#")
The following Python window script demonstrates how to use the CreateDatabaseConnection tool to connect to a point in time.
# Name: CreateDatabaseConnection4.py
# Description: Connects to a point in time in the geodatabase in
# PostgreSQL using database authentication.
# Import system modules
import arcpy
# Run the tool
arcpy.CreateDatabaseConnection_management("C:\\MyProject",
"history.sde",
"POSTGRESQL",
"dbserver",
"DATABASE_AUTH",
"stevie",
"smith",
"SAVE_USERNAME",
"archivedb",
"#",
"POINT_IN_TIME",
"#",
"5/19/2011 8:43:41 AM")
Environments
Licensing information
- Basic: No
- Standard: Yes
- Advanced: Yes