Select to view content in your preferred language

Update Data Source for SQL geodatabase from database authentication to operating system authentication

441
2
Jump to solution
02-12-2024 01:49 PM
Labels (1)
AndreaB_
Occasional Contributor II

Hi All,

I'm using ArcGIS Pro 3.2.1.

I see this doc: https://pro.arcgis.com/en/pro-app/latest/help/projects/update-data-sources.htm# 

Unfortunately, I don't think that helps me. I'm trying to change all of my sources in my aprx from SQL database authentication to SQL windows authentication. I don't want to have to click on each layer individually and go to Set Data Source and navigate to my databases connection that is Windows Auth- but I think that might be the only way. 

Does anyone know of a faster way?

Thank you! 

A

0 Kudos
1 Solution

Accepted Solutions
RyanUthoff
Regular Contributor

This might be what you are looking for. Basically, you'll need change switch out your data source from your old SDE connection file with SQL DB authentication to a new SDE connection file with SQL Windows authentication.

You should be able to do it with a little bit of Python. Although, disclaimer, I have attempted to do this and it ended up not working quite right and I just had to do it manually. I'm not sure if I was just doing something wrong or what. But regardless, I think this page will help you bulk change the data sources.

https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/updatingandfixingdatasources.htm

Depending on how many layers you need to change data sources on, it might be faster to just manually change them as opposed to trying to write some Python code to do it. Just depends on how fast you are and how well it works for you.

View solution in original post

2 Replies
RyanUthoff
Regular Contributor

This might be what you are looking for. Basically, you'll need change switch out your data source from your old SDE connection file with SQL DB authentication to a new SDE connection file with SQL Windows authentication.

You should be able to do it with a little bit of Python. Although, disclaimer, I have attempted to do this and it ended up not working quite right and I just had to do it manually. I'm not sure if I was just doing something wrong or what. But regardless, I think this page will help you bulk change the data sources.

https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/updatingandfixingdatasources.htm

Depending on how many layers you need to change data sources on, it might be faster to just manually change them as opposed to trying to write some Python code to do it. Just depends on how fast you are and how well it works for you.

AndreaB_
Occasional Contributor II

Hi @RyanUthoff ,

Oh, that was it!! Thank you! 

I tried the sample code from that link and ran it in a new notebook in a different aprx:

import arcpy aprx = arcpy.mp.ArcGISProject(r'C:\Projects\YosemiteNP\Yosemite.aprx') aprx.updateConnectionProperties(r'C:\Projects\YosemiteNP\DBConnections\TestGDB.sde',                                                          r'C:\Projects\YosemiteNP\DBConnections\ProductionGDB.sde') aprx.saveACopy(r"C:\Projects\YosemiteNP\YosemiteNew.aprx")

And it worked! 

One thing to note is both .sde connection files had to be in the project folder. I first tried referencing an .sde connection file that was in my Favorites folder and that didn't work.

Thanks again!

0 Kudos