Create ArcSDE Connection File (Data Management)

License Level:BasicStandardAdvanced

Summary

Creates an ArcSDE connection file for use in connecting to ArcSDE geodatabases.

Usage

Syntax

CreateArcSDEConnectionFile_management (out_folder_path, out_name, server, service, {database}, {account_authentication}, {username}, {password}, {save_username_password}, {version}, {save_version_info})
ParameterExplanationData Type
out_folder_path

The folder path where the .sde file will be stored.

Folder
out_name

The name of the ArcSDE Connection file. Use the .sde file extension.

String
server

The ArcSDE Server machine name.

String
service

The ArcSDE Service name or TCP port number.

String
database
(Optional)

For non-Oracle databases only. The DBMS database to connect to.

String
account_authentication
(Optional)
  • DATABASE_AUTHDatabase Authentication. Uses an internal database username and password to connect to the DBMS. You aren't required to type your username and password to create a connection; however, if you don't, you will be prompted to enter them when a connection is established.
  • OPERATING_SYSTEM_AUTHUse Operating system authentication. You do not need to type in a username and password. The connection will be made with the username and password used to log in to the operating system. If the login used for the operating system is not a valid geodatabase login, the connection will fail. Also note if you are creating a connection to a geodatabase stored in Oracle, DB2, or Informix you have to use a direct connection to the database.
Boolean
username
(Optional)

Database username to connect with using Database Authentication.

String
password
(Optional)

The database user password when using Database Authentication.

Encrypted String
save_username_password
(Optional)
  • SAVE_USERNAMESave the username and password in the connection file.
  • DO_NOT_SAVE_USERNAMEDo not save the username and password in the file. Every time you attempt to connect using the file you will be prompted for the username and password.
Boolean
version
(Optional)

The Geodatabase version to connect to.

String
save_version_info
(Optional)
  • SAVE_VERSIONSave the version name in the connection file.
  • DO_NOT_SAVE_VERSIONDo not save the version name in the connection file. Without the version name being saved with the file you will be prompted for the version to connect to each time you access the connection file.
Boolean

Code Sample

CreateArcSDEConnectionFile Example (Python Window)

The following Python window script demonstrates how to use the CreateArcSDEConnectionFile function in immediate mode.

import arcpy
arcpy.CreateArcSDEConnectionFile_management(r'c:\connectionFiles', 'gpserver', '5151', '', 'toolbox', 'toolbox', 'SAVE_USERNAME', 'SDE.DEFAULT', 'SAVE_VERSION')
CreateArcSDEConnectionFile Example 2 (stand-alone script)

The following stand-alone script is a simple example of how to apply the CreateArcSDEConnectionFile function in scripting.

# CreateArcSDEConnection.py
# Description: Simple example showing use of CreateArcSDEConnectionFile tool
 
# Import system modules
import arcpy

# Set variables
folderName = r"c:\connectionFiles"
fileName = "Connection to gpserver.sde"
serverName = "gpserver"
serviceName = "5151"
databaseName = ""
authType = "DATABASE_AUTH"
username = "toolbox"
password = "toolbox"
saveUserInfo = "SAVE_USERNAME"
versionName = "SDE.DEFAULT"
saveVersionInfo = "SAVE_VERSION"

#Process: Use the CreateArcSDEConnectionFile function
arcpy.CreateArcSDEConnectionFile_management (folderName, fileName, serverName, serviceName, databaseName, authType, username, password, saveUserInfo, versionName, saveVersionInfo)

Environments

This tool does not use any geoprocessing environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: No
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
11/18/2013