(Sigh) I thought that a minor upgrade from 10.3 to 10.4 would be uneventful, but unfortunately I have hit a new bug that is painful to work around. I am copying a subset from a spatialite database to a file geodatabase using a View and SQL filter. This was very elegant but now it crashes completely. The tables are large so it is time consuming to create a repeatable standalone demonstration, but if I cannot do that I can appreciate it is hard to track down so here goes as a warning to others.
<CODE>
db = "e:/parcel.sqlite"
pre = '/main.'
for src,filter,tab in [['Legal_Description',"ttl_title_no is not null","Legal_Description"]]:
if not arcpy.Exists(sqlite+"/"+tab):
try:
print tab, filter, db+pre+src, sqlite+"/"+tab
arcpy.management.MakeTableView(db+pre+src, 'view', filter)
count_view = int(arcpy.management.GetCount("view").getOutput(0))
print count_view,"count_view"
if not arcpy.Exists(intermediate_db+'/'+tab):
arcpy.conversion.TableToTable('view', intermediate_db, tab) # crashes here
count_table = int(arcpy.management.GetCount(intermediate_db+'/'+tab).getOutput(0))
print "intermediate table count",tab, count_table
if count_table != count_view:
sys.exit() # give up here assuming that the TableToTable does not crash first
arcpy.conversion.TableToTable(intermediate_db+'/'+tab, sqlite, tab)
print tab, "copied",
except Exception, errmsg:
arcpy.AddError("Error {}\n {}".format(tab,errmsg))
print "Error {}\n {}".format(tab,errmsg), arcpy.GetMessages()
</CODE>
The problem is deadlines, not reporting bugs. I have thought of three workarounds:
Use another system with SQL functions that work on featureclasses eg SQLiteExpertPro, but this is a bit manual.
Copy all the tables into a filegeodatabase (Table to Table works on full tables), very slow
Add pyspatialite and compose sql queries in python. Works but takes time to write.