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

97
1
10-24-2019 09:36 AM
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

Reply
0 Kudos
1 Reply
DuncanHornby
MVP Frequent Contributor

You posted your question under ARCOBJECTS group you should be posting this under PYTHON group

Reply
0 Kudos