|
POST
|
Just for yucks I ran the same code on a Feature Class at the root level instead of in a Feature Dataset. In this scenario the the update does work. Still odd because in the properties window the instance setting is inconsistent In the one that was changed: When set by adding in standard methods it looks like this where the instance shows the database name, but through code it has the path. I did try to change set the instance to use the database name in the target dictionary but that gave a bad datasource
... View more
05-02-2019
11:46 AM
|
0
|
0
|
3023
|
|
POST
|
I notice I did not set the validate parameter to false. I changed this to layer.updateConnectionProperties(source_properties, target_properties, '', False) I am now even more convinced replacing database does not work, because this makes the changes but breaks the connection, because it is not possible to update the fully qualified name of the Feature Dataset through this method. Using this the new output when evaluating the layer.connectionProperties is what was hoped for {'connection_info': {'authentication_mode': 'DBMS',
'database': 'fort_collins',
'db_connection_properties': 'portal07',
'dbclient': 'sqlserver',
'instance': 'sde:sqlserver:portal07',
'password': '<*********>',
'server': 'portal07',
'user': 'gis',
'version': 'sde.DEFAULT'},
'dataset': 'fort_collins.GIS.PipelineAssembly',
'workspace_factory': 'SDE'} Now the dataset is invalid. I notice a couple things. There is no longer a Database shown in the list after the update. The name of the Feature Dataset is still the old name. However, there is nothing in the connectionProperties that allows one to update the Feature Dataset specifically unless I am not seeing it somewhere. I am at a loss, I am fully convinced esri did not think of this need but shaking my head if that is the case because to me it seems one of the most useful reasons one would want to change a datasource
... View more
05-02-2019
09:57 AM
|
0
|
0
|
5979
|
|
POST
|
This is the original code with debug output to show exactly what is being used as source and replace. This is what happens running inside Pro. I have moved the print output inline to help, also shown at bottom. The first print shows the connectionProperties on the layer before running any code. The next shows the same thing but as variable used in the updateConnectionProperties method The next shows the replace variable. Unless I am not seeing something this is replacing every parameter just using the new settings. The database is replaced with the new database name The dataset is replaced with the new fully qualified name of the dataset The final shows the layer.connectionProperties immediately after the replace operation I did run with the 'workspace_factory' property but included but accidentally copied this output and too much effort to redo the entire code shot below After that I break out to simplify and only show the single layer aprx = arcpy.mp.ArcGISProject("CURRENT")
db_source = 'Staging'
db_target = 'fort_collins'
for map in aprx.listMaps():
print(map.name)
for layer in map.listLayers():
if layer.connectionProperties == None:
continue
print(layer.name)
pprint.pprint(layer.connectionProperties)
{'connection_info': {'authentication_mode': 'DBMS',
'database': 'Staging',
'db_connection_properties': 'portal07',
'dbclient': 'sqlserver',
'instance': 'sde:sqlserver:portal07',
'password': '<*********>',
'server': 'portal07',
'user': 'gis',
'version': 'sde.DEFAULT'},
'dataset': 'Staging.GIS.PipelineAssembly',
'workspace_factory': 'SDE'}
#replace db name in fully qualified dataset name
source_dataset = str(layer.connectionProperties['dataset'])
target_dataset = str(source_dataset).replace(db_source, db_target)
source_info = layer.connectionProperties['connection_info']
# target_info is connection_info dictionary with new parameters
target_info = dict(source_info)
target_info['database'] = db_target
target_info['user'] = 'gis'
target_info['password'] = 'gis'
# setup source and target connection_properties
source_properties = {'connection_info': source_info, 'dataset': source_dataset}
target_properties = {'connection_info': target_info, 'dataset': target_dataset}
pprint.pprint(source_properties)
{'connection_info': {'authentication_mode': 'DBMS',
'database': 'Staging',
'db_connection_properties': 'portal07',
'dbclient': 'sqlserver',
'instance': 'sde:sqlserver:portal07',
'password': '<*********>',
'server': 'portal07',
'user': 'gis',
'version': 'sde.DEFAULT'},
'dataset': 'Staging.GIS.PipelineAssembly'}
pprint.pprint(target_properties)
{'connection_info': {'authentication_mode': 'DBMS',
'database': 'fort_collins',
'db_connection_properties': 'portal07',
'dbclient': 'sqlserver',
'instance': 'sde:sqlserver:portal07',
'password': 'gis',
'server': 'portal07',
'user': 'gis',
'version': 'sde.DEFAULT'},
'dataset': 'fort_collins.GIS.PipelineAssembly'}
layer.updateConnectionProperties(source_properties, target_properties)
pprint.pprint(layer.connectionProperties)
{'connection_info': {'authentication_mode': 'DBMS',
'database': 'Staging',
'db_connection_properties': 'portal07',
'dbclient': 'sqlserver',
'instance': 'sde:sqlserver:portal07',
'password': '<*********>',
'server': 'portal07',
'user': 'gis',
'version': 'sde.DEFAULT'},
'dataset': 'Staging.GIS.PipelineAssembly',
'workspace_factory': 'SDE'}
break
break
Map
Pipeline Assembly
# connectionProperties on layer
{'connection_info': {'authentication_mode': 'DBMS',
'database': 'Staging',
'db_connection_properties': 'portal07',
'dbclient': 'sqlserver',
'instance': 'sde:sqlserver:portal07',
'password': '<*********>',
'server': 'portal07',
'user': 'gis',
'version': 'sde.DEFAULT'},
'dataset': 'Staging.GIS.PipelineAssembly',
'workspace_factory': 'SDE'}
#source_properties variable
{'connection_info': {'authentication_mode': 'DBMS',
'database': 'Staging',
'db_connection_properties': 'portal07',
'dbclient': 'sqlserver',
'instance': 'sde:sqlserver:portal07',
'password': '<*********>',
'server': 'portal07',
'user': 'gis',
'version': 'sde.DEFAULT'},
'dataset': 'Staging.GIS.PipelineAssembly'}
#target_properties variable
{'connection_info': {'authentication_mode': 'DBMS',
'database': 'fort_collins',
'db_connection_properties': 'portal07',
'dbclient': 'sqlserver',
'instance': 'sde:sqlserver:portal07',
'password': 'gis',
'server': 'portal07',
'user': 'gis',
'version': 'sde.DEFAULT'},
'dataset': 'fort_collins.GIS.PipelineAssembly'}
#after update layer.connectionProperties
{'connection_info': {'authentication_mode': 'DBMS',
'database': 'Staging',
'db_connection_properties': 'portal07',
'dbclient': 'sqlserver',
'instance': 'sde:sqlserver:portal07',
'password': '<*********>',
'server': 'portal07',
'user': 'gis',
'version': 'sde.DEFAULT'},
'dataset': 'Staging.GIS.PipelineAssembly',
'workspace_factory': 'SDE'}
... View more
05-02-2019
09:27 AM
|
0
|
0
|
5979
|
|
POST
|
Seems that maybe the title needs to be changed to cannot replace the 'database' property. I ran your code switching out the 'user' and 'password' and it works as expected. But it does not work if changing the 'database' property. This was one reason I thought going to the layer level might work better because then I could also change the 'dataset' property to the new fully qualified dataset. In ArcMap I had a process to script changing the datasource and then to publish the maps, save the copy, and publish feature services to a new server from the new maps. This provided a very streamlined approach to moving from dev to qa to prod. As there are over 20 maps this was a big time saver. At this point we will need to do this manually as it seems one cannot change the database through python
... View more
05-02-2019
08:20 AM
|
0
|
1
|
5979
|
|
POST
|
I tried all methods, I only put the sample code for this approach because it is the most granular so I believe as a last effort would show that this does not work. Also my sample has debug code removed as this is not really relevant to what is being done in the functional code. But in all approaches I did as you suggest and had debug code to check if the layer.connectionProperties was changing prior to saving. Documentation for the method also states: When working with enterprise geodatabase layers, a path to a database connection (.SDE) file can only be used for the new_connection_info parameter. The information in the .SDE file can't be used for the current_connection_info parameter because the connection information is coming from the layer in the project, not the file. A more complete discussion and examples of connection property dictionaries are also provided in the connectionProperties section below. Although there is no mention of what should be used as the current_connection_info in this case: But this has been tried without success import arcpy, os, pprint
import traceback
from os import path
project_folder = r'D:\...'
project_file = r'project.aprx'
project_path = os.path.join(project_folder, project_file)
aprx = arcpy.mp.ArcGISProject(project_path)
current = 'full path to currect .sde file'
new = 'full path to new .sde file'
aprx.updateConnectionProperties(current, new, False, True)
aprx.save()
del aprx I have run inside of Pro and run from Visual Studio, neither working.
... View more
05-02-2019
07:49 AM
|
0
|
1
|
5979
|
|
POST
|
This is the basic code that is being used import arcpy, os, pprint
import traceback
from os import path
project_folder = r'D:\...'
project_file = r'project.aprx'
project_path = os.path.join(project_folder, project_file)
aprx = arcpy.mp.ArcGISProject(project_path)
db_source = 'source'
db_target = 'target'
for map in aprx.listMaps():
for layer in map.listLayers():
if layer.connectionProperties == None:
continue
#replace db name in fully qualified dataset name
source_dataset = layer.connectionProperties['dataset']
target_dataset = str(source_dataset).replace(db_source, db_target)
source_info = layer.connectionProperties['connection_info']
# target_info is connection_info dictionary with new parameters
target_info = dict(source_info)
target_info['database'] = db_target
target_info['user'] = 'gis'
target_info['password'] = 'gis'
# setup source and target connection_properties
source_properties = {'connection_info': source_info, 'dataset': source_dataset}
target_properties = {'connection_info': target_info, 'dataset': target_dataset}
layer.updateConnectionProperties(source_properties, target_properties)
aprx.save()
del aprx
... View more
05-01-2019
02:27 PM
|
0
|
0
|
5979
|
|
POST
|
Writing a script to replace the datasource in a project. I have tried doing this by replacing the .sde file path on the apex object. Tried by replacing at the map level and also at the layer level. none of these methods work. It runs without error but open the project back up and everything still pints to the original source. Following samples located here: Updating and fixing data sources—ArcPy | ArcGIS Desktop Has anyone ever gotten this to actually work?
... View more
05-01-2019
11:50 AM
|
0
|
23
|
12592
|
|
POST
|
If that setting is correct are we going to be ok on the upgrade? Should we need to check anything else before proceeding? Thanks -Joe
... View more
04-24-2019
10:19 AM
|
0
|
0
|
3061
|
|
POST
|
Ya, just came across the latter post after publishing and was about to update my post. Thanks for the quick reply -Joe
... View more
04-24-2019
05:55 AM
|
0
|
0
|
3061
|
|
POST
|
Have you looked at where the real bottle neck is? Is it the query (i.e., the actual time to return the records) or the iteration. One thing to consider is that the result set from the Runtime approach is returning Feature objects which I think are going to be more heavy weight than a Sqlite reader row. Once you have the query result set from the portal query you can likely get anything you need through a LINQ so the iteration does not seem to show mush other than the time to loop over a table [That said I have seen other performance issues myself in Runtime, but I don't see this test evaluating a query it evaluates the iteration]
... View more
04-24-2019
05:53 AM
|
0
|
5
|
4360
|
|
POST
|
Hi, There is a very descriptive document on upgrading a single machine Portal installation: Upgrade ArcGIS Enterprise—ArcGIS Enterprise | ArcGIS Enterprise However, I see nothing specific to doing an HA upgrade. We are in the process of starting an upgrade of our installation from 10.5 to 10.7 and was hoping to find this documented, The plan right now is: Backups Upgrade primary portal Upgrade Site Upgrade secondary portal upgrade web adapters upgrade server farm ??? can this been done concurrently ??? upgrade server web adapter(s) We are not hosting data so do not have a hosting server or data store in the mix. It would be great to get some input to validate this approach. Thanks -Joe
... View more
04-24-2019
05:33 AM
|
0
|
4
|
3325
|
|
POST
|
Looks like the issue was the IWA setup. Turned IWA off in IIS and also used the https://machine.loc:7443/arcgis instead of the https://domainname.domain.com:7443/arcgis and it is processing as I type... Thanks -Joe
... View more
04-16-2019
12:53 PM
|
0
|
0
|
5413
|
|
POST
|
I have this same issue in 10.5 trying to do a backup. If I use the domain.com:7443/arcgis I get the 'Unable to generate token' error. I have tried with our siteadmin user and with a administrator in the Windows identity store. If I try the domain.com:7443/arcgis/sharing/rest it redirects to the internal url (which is not a public Url so does not have a cert). If I use this Url I get an ugly java error (I assume because no cert) If I try the domain.com/portal Url without 7443 I also get an ugly java error. I have changed logging to DEBUG level and still have nothing in the logs associated to the issue Thanks -Joe
... View more
04-16-2019
11:22 AM
|
0
|
2
|
5413
|
|
POST
|
Sorry I never updated with solution, but the issue does seem to have been the geometric network. After we dropped the network and regenerated it worked as expected
... View more
04-10-2019
12:30 PM
|
0
|
0
|
2096
|
|
POST
|
Probably better off asking in the Pro API community https://community.esri.com/groups/arcgis-pro-sdk
... View more
04-08-2019
10:52 AM
|
1
|
0
|
888
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-11-2026 09:07 AM | |
| 1 | 10-23-2025 12:16 PM | |
| 1 | 10-19-2022 01:08 PM | |
| 1 | 09-03-2025 09:25 AM | |
| 1 | 04-16-2025 12:37 PM |
| Online Status |
Offline
|
| Date Last Visited |
a month ago
|