Create Database Connection String (Data Management)

Summary

Creates a connection string that geoprocessing tools can use to connect to a database or an enterprise geodatabase.

Usage

  • Use this tool, instead of connection files, when you have an automated geoprocessing workflow (script or model) that uses database or enterprise geodatabase datasets. You can generate a connection string that can be used as input to any geoprocessing tool that supports the specified dataset type, rather than using a path to the database through the connection file workspace.

  • Connections from ArcGIS to Altibase and Netezza are no longer supported.

Parameters

LabelExplanationData Type
Database Platform

Specifies the database platform to which the connection will be made.

  • SQL ServerConnect to Microsoft SQL Server or Microsoft Azure SQL Database.
  • OracleConnect to Oracle.
  • DB2Connect to IBM DB2 for Linux, UNIX, or Windows.
  • PostgreSQLConnect to PostgreSQL.
  • TeradataConnect to Teradata Data Warehouse Appliance.
  • SAP HANAConnect to SAP HANA.
  • DamengConnect to Dameng.
String
Instance

The database server or instance to which the connection will be made.

This parameter value depends on the Database Platform parameter value chosen.

String
Database Authentication
(Optional)

Specifies the type of authentication that will be used.

  • Database authenticationDatabase authentication will be used. An internal database user name and password are used to connect to the database. You aren't required to type your user name and password to create a connection; however, if you don't, you will be prompted to enter them when a connection is established. This is the default.
    Note:

    If the connection file you are creating will provide ArcGIS services with access to the database or geodatabase, or if you want to use the Catalog search to locate data accessed through this connection file, you must type a user name and password.

  • Operating system authenticationOperating system authentication will be used. You do not need to type a user name and password. The connection will be made with the user name and password that were 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.
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
Database
(Optional)

The name of the database to which you will connect. This parameter only applies to PostgreSQL and SQL Server platforms.

String
Dataset Object Name
(Optional)

The name of the dataset or object in the database to which the connection string will point. This connection string can be used as a path to the specified dataset.

String
Data type
(Optional)

The type of dataset or object referred to in the dataset object name. If there are multiple objects with the same name in the database, you may need to specify the data type of the object for which you want to make a connection string.

String
Target Feature Dataset
(Optional)

The name of the feature dataset containing the dataset or object for which you want to make a connection string. If the dataset is not in a feature dataset (for example, if it's at the root of the database), do not specify a target feature dataset.

String
Schema (Oracle user schema geodatabases only)
(Optional)

The user schema geodatabase to which you will connect. The tool will determine if it is connecting to an Oracle database that contains a user-schema geodatabase. If the Oracle database contains a user schema, this option is active; otherwise, it remains inactive. The default option 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. This parameter only applies when connecting to a geodatabase.

Note:

If Historical is selected and a name is not provided, the default transactional version is used. If Point in time is selected and a date is not provided in the Date and Time parameter, the default transactional version is used.

  • TransactionalConnect to a transactional version. If Transactional is selected, the The following version will be used parameter will be populated with a list of transactional versions, and the Date and Time parameter will be inactive. This is the Default.
  • HistoricalConnect to an historical marker. If Historical is selected, the The following version will be used parameter will be populated with a list of historical markers, and the Date and Time parameter will be inactive.
  • Point in timeConnect to a specific point in time. If Point in time is selected, the The following version will be used parameter will be inactive, and the Date and Time parameter will become active.
  • BranchConnect to the default branch version.
String
The following version will be used
(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 and Time
(Optional)

The value representing the date and time that will be used to connect to the database. This parameter is used with archive-enabled data. Use the time picker to choose the appropriate date.

If manually entering a date, the following formats can be used:

  • 6/9/2011 4:20:15 PM
  • 6/9/2011 16:20:15
  • 6/9/2011
  • 4:20:15 PM
  • 16:20:15

Note:

  • If a time is entered without a date, the default date of December 30, 1899, will be used.
  • If a date is entered without a time, the default time of 12:00:00 AM will be used.

Date

Derived Output

LabelExplanationData Type
CIMDATA Connection String

The CIMDATA connection string.

String

arcpy.management.CreateDatabaseConnectionString(database_platform, instance, {account_authentication}, {username}, {password}, {database}, {object_name}, {data_type}, {feature_dataset}, {schema}, {version_type}, {version}, {date})
NameExplanationData Type
database_platform

Specifies the database platform to which the connection will be made.

  • SQL_SERVERConnect to Microsoft SQL Server or Microsoft Azure SQL Database.
  • ORACLEConnect to Oracle.
  • DB2Connect to IBM DB2 for Linux, UNIX, or Windows.
  • POSTGRESQLConnect to PostgreSQL.
  • TERADATAConnect to Teradata Data Warehouse Appliance.
  • SAP HANAConnect to SAP HANA.
  • DAMENGConnect to Dameng.
String
instance

The database server or instance to which the connection will be made.

This parameter value depends on the Database Platform parameter value chosen.

String
account_authentication
(Optional)

Specifies the type of authentication that will be used.

  • DATABASE_AUTHDatabase authentication will be used. An internal database user name and password are used to connect to the database. You aren't required to type your user name and password to create a connection; however, if you don't, you will be prompted to enter them when a connection is established. This is the default.
    Note:

    If the connection file you are creating will provide ArcGIS services with access to the database or geodatabase, or if you want to use the Catalog search to locate data accessed through this connection file, you must type a user name and password.

  • OPERATING_SYSTEM_AUTHOperating system authentication will be used. You do not need to type a user name and password. The connection will be made with the user name and password that were 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.
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
database
(Optional)

The name of the database to which you will connect. This parameter only applies to PostgreSQL and SQL Server platforms.

String
object_name
(Optional)

The name of the dataset or object in the database to which the connection string will point. This connection string can be used as a path to the specified dataset.

String
data_type
(Optional)

The type of dataset or object referred to in the dataset object name. If there are multiple objects with the same name in the database, you may need to specify the data type of the object for which you want to make a connection string.

String
feature_dataset
(Optional)

The name of the feature dataset containing the dataset or object for which you want to make a connection string. If the dataset is not in a feature dataset (for example, if it's at the root of the database), do not specify a target feature dataset.

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. This parameter only applies when connecting to a geodatabase.

  • TRANSACTIONALConnect to a transactional version. If Transactional is selected, the The following version will be used parameter will be populated with a list of transactional versions, and the Date and Time parameter will be inactive. This is the Default.
  • HISTORICALConnect to an historical marker. If Historical is selected, the The following version will be used parameter will be populated with a list of historical markers, and the Date and Time parameter will be inactive.
  • POINT_IN_TIMEConnect to a specific point in time. If Point in time is selected, the The following version will be used parameter will be inactive, and the Date and Time parameter will become active.
  • BRANCHConnect to the default branch version.

Note:

If Historical is selected and a name is not provided, the default transactional version is used. If Point in time is selected and a date is not provided in the Date and Time parameter, the default transactional version is 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:

  • 6/9/2011 4:20:15 PM
  • 6/9/2011 16:20:15
  • 6/9/2011
  • 4:20:15 PM
  • 16:20:15

Note:

  • If a time is entered without a date, the default date of December 30, 1899, will be used.
  • If a date is entered without a time, the default time of 12:00:00 AM will be used.

Date

Derived Output

NameExplanationData Type
out_connection_string

The CIMDATA connection string.

String

Code sample

CreateDatabaseConnectionString example (Python window)

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

import arcpy
data_conn_str = arcpy.CreateDatabaseConnectionString_management("SQL_SERVER",
                                          "utah",
                                          "DATABASE_AUTH",
                                          "gdb",
                                          "gdb", 
                                          "",
                                          "gdb.roads")
arcpy.Buffer_analysis(data_conn_str, r"c:\temp\Buffers.shp", "10 Miles")

Environments

Related topics