AnsweredAssumed Answered

Changing map document data source from File Geodatabase to Sqlite using arcpy

Question asked by sapaplanus on Oct 24, 2019
Latest reply on Nov 4, 2019 by Hornbydd

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

Outcomes