3

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.GetParameterAsText(0)
arcpy.GetParameterAsText(1)

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

2

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.

Your Answer

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

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