HOW TO
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:
The steps describe how to register a new enterprise geodatabase using the add method within the class “arcgis.gis.Datastore”:
import arcgis import json from arcgis.gis import GIS from arcgis.gis.server import Server
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)
gis_server.datastores
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>",
}
}
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
Get help from ArcGIS experts
Start chatting now