Summary
Registers a folder or database with an ArcGIS Server site.
Syntax
AddDataStoreItem (connection_file, datastore_type, connection_name, server_path, {client_path}, {hostname})
Parameter | Explanation | Data Type |
connection_file | For a hosting server, provide the server URL or use the MY_HOSTED_SERVICES keyword. For a stand-alone server, an ArcGIS Server connection file (.ags) representing the server with which you want to register the data. | String |
datastore_type | The type of data being registered.
| String |
connection_name | A name for the folder or database that publishers or administrators will see when they view the server properties. | String |
server_path | The path or connection to the data as identified by the server. If you're registering a DATABASE, this is either the path to a database connection file (.sde) or a string containing the database connection parameters. If you're registering a FOLDER, this is the path to the folder. | String |
client_path | The path or connection to the data as identified by the publisher's machine, if different from the information used by the server. In some cases, the publisher and the server may be referencing physically distinct databases or folders. When you provide the publisher path and the server path, ArcGIS Server automatically corrects the paths at publish time when your map documents and other resources are transferred to the server. If you're registering a DATABASE, provide either the path to a database connection file (.sde) or a string containing the database connection parameters. If you're registering a FOLDER, provide the path to the folder. If you're registering an ArcGIS Server managed database, do not provide a path; instead, provide the string managed for this parameter. An ArcGIS Server managed database is an enterprise geodatabase you designate where data can be copied at publish time if a user attempts to publish a feature service from an unregistered data location. | String |
hostname | The name of the publisher or client machine that will use the registered folder or database. If left blank, the name of the machine running the script will be used. | String |
Data Type | Explanation |
String | If successful, returns the string Success. |
Code sample
Register a local folder, C:\temp, with ArcGIS Server.
import arcpy
conn = "GIS Servers/MyConnection.ags"
path = "c:/temp"
arcpy.AddDataStoreItem(conn, "FOLDER", "My local data folder", path, path)
Register a shared folder, \\MYSERVER\mydata\Washington, with the server, and the local folder, C:\mydata\Washington, is being used by the publisher.
import arcpy
conn = "c:/connections/MYSERVER.ags"
arcpy.AddDataStoreItem(conn, "FOLDER", "Washington",
"//MYSERVER/mydata/Washington",
"c:/mydata/Washington", "MYPUBLISHER")
Register an enterprise database, wilma, used by both the server and the publisher machines. An .sde connection file is created when you add a database connection in the Catalog window of ArcMap.
import arcpy
server_conn = "c:/connections/MYSERVER.ags"
db_conn = "c:/connections/Connection to wilma.sde"
arcpy.AddDataStoreItem(server_conn, "DATABASE", "Wilma", db_conn, db_conn)
Register an enterprise database, wilma, with a stand-alone server, and the database, pebbles, is being used by the publisher.
import arcpy
server_conn = "c:/connections/MYSERVER.ags"
db_conn_serv = "c:/connections/Connection to wilma.sde"
db_conn_pub = "c:/connections/Connection to pebbles.sde"
arcpy.AddDataStoreItem(
server_conn, "DATABASE", "WilmaAndPebbles", db_conn_serv, db_conn_pub)
Register an enterprise database, wilma, as an ArcGIS Hosting Server managed database. If a publisher attempts to publish a feature service from an unregistered data location, the data will be copied here.
import arcpy
server_conn = "https://www.MYSERVER.com/server"
db_conn_serv = "c:/connections/Connection to wilma.sde"
arcpy.AddDataStoreItem(
server_conn, "DATABASE", "WilmaManaged", db_conn_serv, "managed")
Register an enterprise database, serverX, with the server using a database connection string.
import arcpy
server_conn = "c:/connections/MYSERVER.ags"
db_conn_string = u"PASSWORD=pwdX;SERVER=serverX;" + \
u"INSTANCE=sde:sqlserver:serverX;DBCLIENT=sqlserver;" + \
u"DB_CONNECTION_PROPERTIES=serverX;" + \
u"DATABASE=sde;USER=userX;AUTHENTICATION_MODE=DBMS"
arcpy.AddDataStoreItem(
server_conn, "DATABASE", "ServerX", db_conn_string, db_conn_string)