Hello everybody,
I have a script tool and I want to add the output file geodatabase from my script to aprx databases. But arcpy.mp.ArcGISProject.databases is a read-only property.
Is there a way with arcpy or via CIM or calling ArcGIS Pro SDK in arcpy?
Solved! Go to Solution.
Sorry,
I missed the method arcpy.mp.ArcGISProject.updateDatabases(databases, {validate})
Sorry,
I missed the method arcpy.mp.ArcGISProject.updateDatabases(databases, {validate})
Hi,
I'm struggling at the same step. I "just" want to add my gdb to my current project.
I do not find the documentation on it. I tried your example but I'm missing one parameters
gdb = r"*\MyGDB.gdb"
arcpy.env.workspace = gdb
arcpy.mp.ArcGISProject.updateDatabases(gdb)
aprx.save()
del aprx
But I get:
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) 6 arcpy.env.workspace = gdb 7 ----> 8 arcpy.mp.ArcGISProject.updateDatabases(gdb) 9 aprx.save() 10 del aprx TypeError: updateDatabases() missing 1 required positional argument: 'databases'
Can you give a code example with parameters ?
Thanks,
Alex
Sorry,
the database parameter of the updateDatabases method requires a list of Python dictionaries, but not a string/path of a geodatabase. This is well documented here.
aprx = arcpy.mp.ArcGISProject('Current')
gdbs = aprx.databases
# change the list of Python dictionaries
# gdbs.append({'databasePath': '<A local or UNC path to a database>', 'isDefaultDatabase': False})
aprx.updateDatabases(gdbs)
aprx.save()