Select to view content in your preferred language

MakeTableView_management causes an exception when outside of ArcMap

1230
6
06-04-2012 09:55 AM
SteveLong
Occasional Contributor
Hello,
I'm trying to script the process of creating a replica in a stand alone python script. The geodatabase I'm creating the replica for, (CHECK_OUT type), includes business table I that want in the file geodatabase. If I execute the following line of code in ArcMap in the python window it works well and ArcMap adds the view to the current map. And, it persists from session to session.

arcpy.MakeTableView_management("VegetationMgmt.owner.Actions", "Actions", "AID > 0")

However, when I execute it in a stand alone script after setting up the workspace:
env.workspace = "...\SpatialVegMgmt_NT38.sde"

it produces an error of VegetationMgmt.owner.Actions already exists.

Can anyone help on why it works inside ArcMap but not outside?

Steve
Tags (2)
0 Kudos
6 Replies
MathewCoyle
Honored Contributor
Have you set your overwriteoutput in your code?
env.overwriteOutput = True
0 Kudos
SteveLong
Occasional Contributor
Hmmm, no I have not. That would not overwrite the original table would it?

Steve
0 Kudos
MathewCoyle
Honored Contributor
Yes, that is what you are doing in your code by setting your workspace to SDE and creating the tableview with the same name as the source.
0 Kudos
SteveLong
Occasional Contributor
Hmm,
when I execute that line of code in ArcMap, in the python window, it creates a tableView "Actions". The source table is VegetationMgmt.owner.Actions and it doesn't overwrite that source table.

Forgive my ignorance but I'm really new to this...

Thanks
Steve
0 Kudos
MathewCoyle
Honored Contributor
I would suspect it is because you are using the default workspace in ArcMap and setting SDE as your workspace in your stand-alone script.
0 Kudos
SteveLong
Occasional Contributor
Thanks for your replies Mathew. That did the trick. I changed the workspace to sde.DEFAULT and the maketableview executed without a hitch. Now I'm getting another error when I try to create the replica but I'll re-post as it's a different topic.

Steve
0 Kudos