I have sql constraint defined like this:
_sql_constraints = [
('checksum_uniq', 'unique(checksum)', ' The same file already exists in the system!'),
]
Then in a loop I create records
for file in files:
try:
self.env[model].create({'filename':file.fname,'file':file.file_data})
except IntegrityError, e:
print 'skipping file ' + file.fname
The problem is that the cursor is closed after IntegrityError so the loop fails after that but I want to skip the records that fail and continue the loop.