Select to view content in your preferred language

How to Set/Un-Set a Service Lock Database Schema Property Using ArcGIS API for Python

625
1
Jump to solution
11-28-2023 08:33 PM
BHK
by
New Contributor III

Can someone please let me know if there is a way that we can set/unset a service Lock Database Schema by using ArcGIS ArcGIS API for Python

 

BHK_0-1701232205662.jpeg

 

 

0 Kudos
1 Solution

Accepted Solutions
EarlMedina
Esri Regular Contributor

This IS possible, but you have to be very careful that you provide the exact JSON representation of your service (plus the update to the "schemaLockingEnabled" property) as a dict. I tested the below with good results, but I suggest you carefully review the service properties for correctness and use a test service to start.

from arcgis.gis import GIS

gis = GIS("https://machine.domain.com/portal", "user", "pass")
hosting_server = gis.admin.servers.get(role="HOSTING_SERVER")[0]
services = hosting_server.services.list()
service = services[0]

# You can get the required dict for the edit from service.properties
# Review for accuracy as this update could break your service if there are
# any errors present
edit_dict = service.properties.__dict__["_mapping"] 
edit_dict["properties"]["schemaLockingEnabled"] = "false"
service.edit(edit_dict)

 

View solution in original post

1 Reply
EarlMedina
Esri Regular Contributor

This IS possible, but you have to be very careful that you provide the exact JSON representation of your service (plus the update to the "schemaLockingEnabled" property) as a dict. I tested the below with good results, but I suggest you carefully review the service properties for correctness and use a test service to start.

from arcgis.gis import GIS

gis = GIS("https://machine.domain.com/portal", "user", "pass")
hosting_server = gis.admin.servers.get(role="HOSTING_SERVER")[0]
services = hosting_server.services.list()
service = services[0]

# You can get the required dict for the edit from service.properties
# Review for accuracy as this update could break your service if there are
# any errors present
edit_dict = service.properties.__dict__["_mapping"] 
edit_dict["properties"]["schemaLockingEnabled"] = "false"
service.edit(edit_dict)