Thursday, May 9, 2013

How to Create a Row with an Empty BLOB in ArcPy

Insert and Update cursor do now support None type in Blob fields, so what does one do?  If you try to set your row object to 'None' you get this error message:
expected contiguous memoryview. type: NoneType
Now let's assume you want to pass None, because for some record you do not have an object that you need to pass for that field.  Use the Memoryview object to solve this problem.  The documentation on the object can be found here.

The python document describe the object as such:
A memoryview object exposes the new C level buffer interface as a Python object which can then be passed around like any other object.
Now in our context, we must do the following:
row[0] = memoryview('')
That's it. Now we have something similar to 'None' for your blob field.

I also posted a quick tutorial on read/writing blob data using arcpy.da here.


Please support this idea of having GUI designer in python built in with python add-ins.
It can be found here. (direct link: http://ideas.arcgis.com/ideaView?id=087E00000004SmHIAU)


Enjoy