Changing map document layer data sources from file gdb to sqlite/spatialite using arcpy

237
0
02-18-2020 03:19 PM
StevenPaplanus
New Contributor III

I need to write an arcpy script which will allow me to change the layers of a map document to point from a file geodatabase to a sqlite database with the same table names and data.

 

I was able to use the following to migrate from a gdb to a sql server database:

import arcpy

mxd = arcpy.mapping.MapDocument(r"C:\test\mytestmap.mxd")

mxd.replaceWorkspaces(r"C:\test\src.gdb","FILEGDB_WORKSPACE",r"C:\test\dest.sde","SDE_WORKSPACE")

mxd.SaveACopy(r"C:\test\newmap.mxd")

 

I tried to do the same with this code:

import arcpy

mxd = arcpy.mapping.MapDocument(r"C:\test\mytestmap.mxd")

mxd.replaceWorkspaces(r"C:\test\src.gdb","FILEGDB_WORKSPACE",r"C:\test\dest.sqlite","SDE_WORKSPACE")

mxd.SaveACopy(r"C:\test\newmap.mxd")

 

I have tried to use the destination workspace as SDE_WORKSPACE,FILEGDB_WORKSPACE, and  TEXT_WORKSPACE, but i only get "ValueError: MapDocObject: Unexpected error"

 

Is there another way to do this work or am I missing a step?  I need to do a batch of documents and will need to do it again in the future, so a script is the best way to proceed, if I can.

 

Steve

0 Kudos
0 Replies