CreateDatabaseConnection_management doesn't return an error for no-existing user

2681
2
07-22-2013 08:50 AM
SchoppMatthieu
New Contributor III
I've tested the "arcpy.CreateDatabaseConnection_management" and I found out that, unlike the manual process, it's possible to create a connection file from invalid user's login without receiving any alert message:

try:
     arcpy.CreateDatabaseConnection_management(my valid parameters, non-existing user)
except Exception as (e):
     return


The connection file is created anyway.

Should it be possible to had a new parameter to the method in order to check if the connection  works ? (like the "validate" parameter of the MapDocument "findAndReplaceWorkspacePaths" method ) ?

For now I fixed it by using "arcpy.ListUsers(myConnection)" to test the connection.
Is there a better way of doing it ?
Tags (2)
0 Kudos
2 Replies
SchoppMatthieu
New Contributor III
Same thing for "CreateGISServerConnectionFile" 😞
0 Kudos
MathewCoyle
Frequent Contributor
You've found a good workaround yourself. Creating a connection file is wholly independent from connecting to the database and you can't really test the connection until you create the connection file.
0 Kudos