I have to insert a good amount of log records every hour in a table and I would not care about Integrity Errors or Violations that happen in the process.
If I disable autoCommit and do a bulk insert, cursor wont insert anything beyond the row where the transaction failed. Is there a way around this one ?
One hack is to handle this at the application level. I could implement a n-sized buffer and do bulk inserts. If something failed in that transaction, recursively repeat the insert for buffer_first_half + buffer_second_half
def insert(buffer):
try:
bulk_insert(buffer)
except:
connection.rollback()
marker = len(buffer)/2
insert(buffer[:marker])
insert(buffer[marker:])
But I really hope if it could be achieved using any Postgres' built-in ?