ListUsers (arcpy)
サマリ
Returns a list of named tuples containing information for users who are connected to an enterprise geodatabase.
説明
The ListUsers function is used by an administrative user to identify users who are currently connected to an enterprise geodatabase.
- The ListUsers function must utilize an administrative connection to the database.
- This function will fail if attempted by a nonadministrative user.
構文
パラメータ | 説明 | データ タイプ |
sde_workspace |
An enterprise geodatabase (sde connection file). The connection properties specified in the enterprise geodatabase must have administrative rights that allow the user to disconnect other connections. | String |
データ タイプ | 説明 | ||||||||||||||||||
tuple |
The ListUsers function returns a list of named tuples. The named tuples returned each have the following five items:
|
コードのサンプル
import arcpy
arcpy.ListUsers("Database Connections/admin.sde")
The following example demonstrates how to print a list of connected users along with their connection time.
import arcpy
users = arcpy.ListUsers("Database Connections/admin.sde")
for user in users:
print("Username: {0}, Connected at: {1}".format(
user.Name, user.ConnectionTime))
The following example demonstrates how to generate a new list of only SDE IDs from the list returned by ListUsers.
import arcpy
# Set the admistrative workspace connection
arcpy.env.workspace = "Database Connections/tenone@sde.sde"
# Create a list of users
'''
NOTE: When the arcpy.env.workspace environment is set, a workspace
does not need to be provided to the function.
'''
users = arcpy.ListUsers()
# Create a list of SDE ID's.
# Use a list comprehension to get the ID values in a new list.
id_users = [user.ID for user in users]
print(id_users)