Hello, so I want to deploy my python add-in for any of the users to use, and I have my connection to a SDE feature class hardcoded in the script , which works fine. I got this connection from ArcCatalog.
C:\Users\jthomas\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog + featureClass
Now if someone else installs the add-in, they'll have their own connection to the SDE feature class. How can I ensure other users will be able to reach this feature class, and the script won't break?
You can use the connection like this assuming that the other users used the same name for the connection:
sde = r'Database Connections\Name of your Connection.sde'
You can also provide the sde file with toll applying a relative folder structure (see this page: Paths explained: Absolute, relative, UNC, and URL—Help | ArcGIS for Desktop ), but then for instance in case of Oracle you would need the same named entry in the tnsnames.ora file at that users site.
Or include the connection as a parameter in the tool and let the user select the connection and validate is the required data is accessible. Many options, all depend on how your organization has designed its infrastructure.
Thanks Xander, I think I only have to safeguard against 2 situations: A local installation where the connection would be : C:\Users\jthomas\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\database.sde
db = sqlserver
and then a citrix installation where the ArcMap version is the same (10.2), but Catalog is 10.0, which means the connection is:
C:\Users\jthomas\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\Connection to database.sde
db = sql server
So the version number is changing, and the end of the string changes from "database.sde" to "connection to database.sde".
I guess I could add a button that toggles the connection string, but I was hoping for a good way to detect the environment, and then just use the proper connection.
One would think, but this is the core of my problem. if I just put 'Database Connections\dbname.sde', the other one will error out (the one with 'Connection to dbname.sde'). I'll keep digging.
Depending on if you need specific user permissions or not, you may try the suggestion to create a .sde connection that will work for all and include it in the addin...you can refer to it with a relative path.
Or create a common one and have it located in a secure location on you network where all can reach and point to that .sde connection.
i have used both methods successfully, and it all just depends on the the permissions needed to access the data and what permissions the addin require.