I am writing a script that accesses multiple sde Database connections. I have set the script to include accessing the environment workspace:

import arcpy


arcpy.env.workspace = r"Database Connections\somedb.sde"

do some python stuff...

arcpy.env.workspace = r"Database Connections\someOtherdb.sde"

So, I open then tool, enter my parameters and run it. When it gets to setting the workspace, I get the regular popup window to prompt me to enter my username and password to the sde database.

The problem I have it that the tool GUI runs on top of the popup. Any time I try to click on the popup window to enter my username and password, the GUI automatically pops on top again and I can't type anything.

Is there any way for me to build the GUI so that I can enter my username and password aside from using the arcpy.CreateArcSDEConnectionFile_management function? My connection files already exist, so I don't need to create new ones. I just need to log in to it.

1 Answer 1


After testing I found a solution that is working for now. I just went into the validator class and set the workspace environment for both database connections to initiate on tool startup. Now, when I open the tool, I get the Database Connection login prompt to popup twice (one for each DB connection) and I can enter my login information.

Ideally though, I would like to build my ArcGIS GUI to include a string parameter for the username and an encrypted string parameter to accept the password which I would pass along to the connection file prompt. If I find a solution, I will post an answer.

  • I'm 10 years too late.... But is there any chance you could share was you entered into the ToolValidator class? I'm trying to do something similar. I want to have the database login prompt pop up when the tool is opened.
    – S. Price
    Commented May 14 at 21:34
  • Apologies, but I lost the code for this one. If I remember correctly, I just set arcpy.env.workspace = r'Database Connections\MYDB.sde' within the initializeParameters(self) function. I have since moved on to integrating credentials within the GUI itself.
    – Mike
    Commented May 23 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.