HOW TO

Register an enterprise geodatabase to ArcGIS Server using the ArcGIS API of Python

First Published: November 26, 2025
Last Published: June 18, 2026

Summary

This article provides a step-by-step guide on how to register an enterprise geodatabase as a data store item to an ArcGIS Server using the ArcGIS API for Python. The script utilizes the arcgis library to connect to the ArcGIS Server Admin API and register a new enterprise geodatabase (EGDB).

Before running the script, ensure you meet the following requirements: 

  • Access to an ArcGIS Server with administrative privileges
  • The necessary connection details for your enterprise geodatabase
  • Ensure the arcgis package is installed in your Python environment

Procedure

The steps describe how to register a new enterprise geodatabase using the add method within the class “arcgis.gis.Datastore”: 

  1. Import the necessary libraries. 
import arcgis
import json 
from arcgis.gis import GIS 
from arcgis.gis.server import Server
  1. Specify the ArcGIS Server details.
server_admin_url = '<server admin URL>'
gis = arcgis.gis.GIS(url=r'<portal url>', username='<portal admin username>', password='<portal admin password>')
gis_server = Server(server_admin_url, gis) 
  1. Accessing the data store path from the ArcGIS Server Admin API. 
gis_server.datastores  
  1. Create a dictionary representing the data item with the name of the item to be added on the server: 
itemDict = { 
  "path": "/enterpriseDatabases/datastore_name", 
  "type": "egdb", 
  "totalRefCount": 0, 
  "info": { 
    "dataStoreConnectionType": "shared", 
    "isManaged": False, 
    "connectionString": "<the encrypted connection string for the ArcGIS Server to connect to enterprise database>",
  } 
} 
  1. Register the data store item: 
gis_server.datastores.add(itemDict)
Note: 
The connection string parameter should appear as shown below, and it is generated automatically when we attempt to register a datastore using the .sde file from the ArcGIS Server Manager. Additionally, ArcGIS Pro tools can also be used to create this encrypted connection string.
“ENCRYPTED_PASSWORD_UTF8=00022e684b754f4f38634b4f7a613951525a61737933442b77673d3d2a00;ENCRYPTED_P
ASSWORD=00022e6879685a4a542b6f64422f2f75416c44584a6a2f4341773d3d2a00;SERVER=aspen;INSTANCE=sde:postg
resql:aspen;DBCLIENT=postgresql;DB_CONNECTION_PROPERTIES=aspen;DATABASE=pglakehume;USER=sde;VERSION=s
de.DEFAULT;AUTHENTICATION_MODE=DBMS”

Article ID: 000039240

Software:
  • ArcGIS Server
  • ArcGIS API for Python

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options