AddDataStoreItem (arcpy)

摘要

在 ArcGIS Server 站点注册文件夹或数据库。有关应注册数据的时间和原因,请参阅关于将您的数据注册到服务器

讨论

有关应在 ArcGIS Server 上注册数据的时间和原因,请参阅关于将您的数据注册到服务器

语法

AddDataStoreItem (connection_file, datastore_type, connection_name, server_path, {client_path}, {hostname})
参数说明数据类型
connection_file

An ArcGIS Server connection file (.ags) representing the server with which you want to register the data. If you've made a connection in ArcCatalog you can use the connection file found in your user profile directory. Alternatively, you can create a connection file from scratch using the function CreateGISServerConnectionFile.

String
datastore_type

The type of data being registered.

  • DATABASEThe data resides in an enterprise database.
  • FOLDERThe data is file-based.
String
connection_name

A name for this 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 seen by the server.

If you are registering a DATABASE, this is either the path to a database connection file (.sde) or a string containing the database connection parameters. See Database connections in ArcGIS Desktop to learn how to obtain this file or string.

If you are registering a FOLDER, this is the path to the folder.

String
client_path

The path or connection to the data as seen 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 are registering a DATABASE, provide either the path to a database connection file (.sde) or a string containing the database connection parameters. See Database connections in ArcGIS Desktop to learn how to obtain this file or string.

If you are registering a FOLDER, provide the path to the folder.

If you are registering ArcGIS Server's Managed Database, do not provide a path; instead, provide the string managed for this parameter. ArcGIS Server's 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. See Copying data to the server automatically when publishing to learn more.

String
hostname

The name of the publisher or client machine that will use this registered folder or database. If left blank, the name of the machine running the script will be used.

String
返回值
数据类型说明
String

如果操作成功,将返回字符串 "Success"

代码实例

注册一个由服务器和发布程序使用的文件夹

在 ArcGIS Server 上注册本地文件夹 C:\temp。假设已在 ArcMap 的目录 窗口创建了与服务器的连接,并重命名为 MyConnection。

import arcpy

conn = "GIS Servers/MyConnection.ags"
path = "c:/temp"

arcpy.AddDataStoreItem(conn, "FOLDER", "My local data folder", path, path)
注册一个在服务器和发布程序之间有所不同的文件夹

将共享文件夹 \\MYSERVER\mydata\Washington 注册到服务器,而本地文件夹 C:\mydata\Washington 由发布程序使用。

import arcpy

conn = "c:/connections/MYSERVER.ags"

arcpy.AddDataStoreItem(conn, "FOLDER", "Washington",
                       "//MYSERVER/mydata/Washington",
                       "c:/mydata/Washington", "MYPUBLISHER")
注册一个由服务器和发布程序使用的数据库

注册一个由服务器和发布程序计算机使用的企业级数据库 wilma。使用在 ArcMap 目录 窗口中添加数据库连接时创建的 .sde 连接文件。

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)
注册一个在服务器和发布程序之间有所不同的数据库

将企业级数据库 wilma 注册到服务器,而数据库 pebbles 由发布程序使用。

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)
将数据库注册为 ArcGIS Server 的托管数据库

将企业级数据库 wilma 注册为 ArcGIS Server 的托管数据库。如果发布程序试图从未注册的数据位置发布要素服务,则数据将复制到此处。

import arcpy

server_conn = "c:/connections/MYSERVER.ags"
db_conn_serv = "c:/connections/Connection to wilma.sde"

arcpy.AddDataStoreItem(
    server_conn, "DATABASE", "WilmaManaged", db_conn_serv, "managed")
使用连接字符串注册数据库

使用数据库连接字符串将企业级数据库 serverX 注册到服务器。

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)

相关主题

5/10/2014