POST
|
This sample code i am running sucessfully on oracle db import arcpy, os, pprint import traceback from os import path project_folder = r'D:\Project\' project_file = r'sample.aprx' project_path = os.path.join(project_folder, project_file) aprx = arcpy.mp.ArcGISProject(project_path) Source_fc = 'SM.sm__installs' target_fc = 'SM.sm__installs' targetInstance = 'sde:oracle$sde:oracle11g:ABCD_P' targetUser = 'sde' targetPwd = 'sde123' for map in aprx.listMaps(): for layer in map.listLayers(): if layer.connectionProperties == None: continue sourceConn = layer.connectionProperties targetConn = sourceConn print(sourceConn) targetConn['dataset'] = target_fc #which is not required if pointing to same fc in other database targetConn['connection_info']['instance'] = targetInstance targetConn['connection_info']['user'] = targetUser targetConn['connection_info']['password'] =targetPwd #targetConn['connection_info']['db_connection_properties'] ='xDatabase/xInstance' # this is required for SQL db print(targetConn) layer.updateConnectionProperties(sourceConn, targetConn) aprx.save() del aprx
... View more
05-03-2019
07:54 AM
|
0
|
1
|
765
|
POST
|
There are lot of confusions over names dataset from arcpy's 'connection_info' to desktop ArcGIS Pro layer properties. arcpy's 'connection_info' dataset means featureclass name but in desktop ArcGIS Pro is different. only instance, and db_connection_properties in connection_info has to be set properly, as you know, in database and in Arc Pro property there is know value for dataset , if you keep instace, db_connection_properties properly and dataset as featureclass name it will resolve the issue. and if change feature class name in layer properties then it fine dont worry about other values, still esri has to modify their layer property dialog box. It is not important to this method where featureclass is whether it is in dataset(Arc Catalog/ArcMap terminolgy) or at root level. I am successfully changing databases with is method without watching layer property dialog box.
... View more
05-02-2019
12:00 PM
|
0
|
4
|
765
|
POST
|
Few observations I found from you code, target_info['database'] = db_target ----- this is not setting the property instead it is
adding additional values to target_info; may be you can use replace method; arcpy
don't have rich JSON functions.
this is source connection property
{'dataset': 'FeatureClass Name, 'workspace_factory': 'SDE', 'connection_info':
{'authentication_mode': 'DBMS', 'database': 'FeatureClassName', 'dbclient': 'oracle',
'db_connection_properties': 'database/instance', 'password': '<*********>',
'instance': 'sde:'database/instance', 'server': 'serverName',
'user': 'user', 'version': 'SDE.DEFAULT'}}
but target_properties is {'dataset': 'FeatureClass Name, 'workspace_factory': 'SDE', 'connection_info':
{'authentication_mode': 'DBMS', 'database': 'FeatureClassName', 'dbclient': 'oracle',
'db_connection_properties': 'database/instance', 'password': '<****>',
'instance': 'sde:'database/instance', 'server': 'serverName',
'user': 'user', 'version': 'SDE.DEFAULT'},{'dataset': 'FeatureClass Name,
'workspace_factory': 'SDE', 'connection_info': {'authentication_mode': 'DBMS',
'database': 'FeatureClassName', 'dbclient': 'oracle',
'db_connection_properties': 'database/instance', 'password': '<****>',
'instance': 'sde:'database/instance', 'server': 'serverName',
'user': 'user', 'version': 'SDE.DEFAULT'}}
Make sure db_connection_properties,'instance' has to be set properly based on
database changes.
And Also
db_source = has to be existing feature class name,
db_target = has to be target feature class name
most of the time both are same when we doing one database connection to
other connection.
- Problem occurring only when you replacing source info to target info values
- more over tool is not giving errors, this may be bug.
I am able run the tools successfully.
... View more
05-02-2019
08:19 AM
|
0
|
0
|
2159
|