Database issues have now been resolved. The failed inserts came from using single instead of double quotes to surround the strings being placed in the table, as the strings could contain single quotes that caused them to terminate early. Also, the out of memory issues was caused by a quirk in the way Python handles default parameters that I was unaware of. It has now been resolved.