Select to view content in your preferred language

Setting Env. in Python when you are working with 2 databases on separate servers

1895
4
Jump to solution
12-22-2016 08:40 AM
deleted-user-t3dSviijg-m9
Deactivated User

I've attached the script I am working on. It is a basic script set-up to sync changes between two replicated sde geodatabases. They are replicated fine, and manual sync works fine but I've been wanting to automate it. The thing I'm unsure of, is... what do I set the environment to if both of these databases exists on different SQL Servers?

The only python scripts I have created have to do with reconciling version or compressing an sde, but for all of that, the environment is just a single SDE database. 

What do I do if the script needs to interact with two databases not in the same location?

0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

My suggestion, don't bother setting the workspace unless the tool absolutely requires it.  Use full paths to workspaces, geodatabases, etc...

View solution in original post

4 Replies
JoshuaBixby
MVP Esteemed Contributor

Looking at the attached script, the basic question boils down to calling arcpy.SynchronizeChanges_management.  Instead of setting a workspace (arcpy.env.workspace) and passing only the SDE connection file name, pass the full path to the SDE connection files.  I don't know if it is a best practice or not, but I always pass full paths to geodatabases and SDE connection files because then I am not dependent on what the workspace is set to.

0 Kudos
deleted-user-t3dSviijg-m9
Deactivated User

This makes sense. It didn't dawn on me but, I keep all my SDE connection files in the same folder. I could essentially set the full file path to that folder as the workspace right? Alternatively, in this case... I'm not sure if I need to set a workspace. If I specify each gdb in the parameters of arcpy.SynchronizeChanges_management, I don't think a workspace is necessary since the gdb's are "hardcoded" into the script essentially. I think so?

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

My suggestion, don't bother setting the workspace unless the tool absolutely requires it.  Use full paths to workspaces, geodatabases, etc...

BlakeTerhune
MVP Regular Contributor