AcceptConnections (arcpy)

摘要

允许管理员启用或禁用非管理员用户连接到企业级地理数据库的功能。

讨论

管理员可使用 AcceptConnections 函数暂时阻止到企业级地理数据库的连接。该函数用于补充 ArcGIS for Desktop 中企业级地理数据库属性页面中的“连接”选项卡。

语法

AcceptConnections (sde_workspace, accept_connections)
参数说明数据类型
sde_workspace

The Enterprise geodatabase that will have its connection property altered.

The connection properties specified in the Enterprise Geodatabase must be the geodatabase administrator.

String
accept_connections

Boolean value indicating if the geodatabase will accept connections (True) or will not accept connections (False).

Boolean

代码实例

AcceptConnections 示例 1

以下示例说明了如何阻止到地理数据库的连接。

import arcpy

arcpy.AcceptConnections("Database Connections/admin.sde", False)
AcceptConnections 示例 2

以下示例说明了如何阻止到地理数据库的连接、断开活动连接,以及如何运行地理数据库压缩程序。

import arcpy

# Set Admin workspace variable
admin_workspace = "Database Connections/admin.sde"

# Block connections
arcpy.AcceptConnections(admin_workspace, False)

# Disconnect users
arcpy.DisconnectUser(admin_workspace, 'ALL')

# Reconcile/Post using default parameters.
arcpy.ReconcileVersions_management(admin_workspace, 'ALL_VERSIONS',
                                   'sde.DEFAULT', with_post='POST')

# Compress the geodatabase
arcpy.Compress_management(admin_workspace)

# Allow connections.
arcpy.AcceptConnections(admin_workspace, True)

相关主题

5/10/2014