Changing SDE data source using Python: query layers vs feature layers

951
2
07-28-2016 02:29 AM
Occasional Contributor

I have a bunch of MXD and I need to change the SDE connection in them using Python. These MXD include sde feature layers, sde tables and query layers.

For sde feature layers and tables replaceWorkspaces work as expected but it does not for query layers.

I tried with findAndReplaceWorkspacePaths and it works for query layers but NOT for sde feature layers.

So I guess I should combine both methods to get all the layers' connections changed, but this means changing the data source twice for every MXD. Isn't there a single method to do this all at once? I need all the process to be as fast as possible.

Reply
0 Kudos
2 Replies
Esri Esteemed Contributor

What if you detect the type of data source and apply the suitable method per layer type?

Reply
0 Kudos
Occasional Contributor

I may be wrong but my guess is that changing the data source for each layer separately will be slower.

Also, the only way to detect if a layer is a query layer is to look for the string '%' in its datasetName as mentioned here. I haven't tested it though.

Reply
0 Kudos