描述
列出工作空间中的复本。
讨论
可以指定作为函数参数的连接文件的路径,或为连接文件设置工作空间环境并调用不带任何参数的 ListReplicas 函数。
语法
ListReplicas (workspace, {all_replicas})
参数 | 说明 | 数据类型 |
workspace | 地理数据库工作空间。 | String |
all_replicas | 指定是否返回地理数据库中的所有复本类型。
(默认值为 False) | Boolean |
数据类型 | 说明 |
Replica | 从包含 Replica 对象的函数返回的列表。 如果 all_replicas 参数已设置为 True,则也可能会返回 SyncReplica 对象。 |
代码示例
为作为发送方的工作空间中的各个复本调用 ExportDataChangeMessage 函数。
import arcpy
import os
sdeConnection = "C:/Data/toolboxDEFAULTVersion.sde"
outLocation = "C:/data"
for replica in arcpy.da.ListReplicas(sdeConnection):
# If the replica is a sender, call ExportDataChangeMessage
if replica.isSender:
changesFile = os.path.join(outputLocation,
"changes_{0}.gdb".format(replica.name))
arcpy.ExportDataChangeMessage_management(sdeConnection,
changes,
replica.name)
打印所有存在冲突的复本。
import arcpy
sdeConnection = "C:/Data/toolboxDEFAULTVersion.sde"
# Print the name of the replicas that are in conflict
#
for replica in arcpy.da.ListReplicas(sdeConnection):
if replica.hasConflicts:
print(replica.name)
打印 SyncReplica 对象的属性
# Import required modules
import arcpy
# Use the ListReplicas function to return all replicas in the geodatabase
replicas = arcpy.da.ListReplicas("C:\\Projects\\MyProject\\myGDB.sde", True)
for r in replicas:
# Check if the class is a SyncReplica
if isinstance(r, arcpy.da.SyncReplica):
# Print the properties of a SyncReplica object
print("Properties of replica named: {}".format(r.name))
print("Datasets: {}".format(r.datasets))
print("Owner: {}".format(r.owner))
print("Replica ID: {}".format(r.replicaID))
print("Service name: {}".format(r.serviceName))
print("Version: {}".format(r.version))
print("Direction: {}".format(r.direction))
print("Sync model: {}".format(r.syncModel))
print("Last sync date: {}".format(r.lastSyncDate))
print("LayerServerGens: {}".format(r.layerServerGens))
print("LayerServerSibGens: {}".format(r.layerServerSibGens))
print("ReplicaServerGen: {}".format(r.replicaServerGen))
print("ReplicaServerSibGen: {}".format(r.replicaServerSibGen))
print("Target type: {}".format(r.targetType))