convert postgres dump insert to batch transaction?

I am searching for a tool/script to convert a postgresql dump file of gigabytes size to a batch transaction commit file.

it should insert BEGIN and COMMIT of transactions in the dump file like so:

BEGIN;
CREATE...;
INSERT...;
INSERT...;
INSERT...;
...
COMMIT;
BEGIN;
CREATE...;
INSERT...;
INSERT...;
INSERT...;
....

Yes. Anything would be better than insert statements. The problem is that the data consists of gigabytes of insert statements and the delivering partner is not reachable to send another dump format.

Do you know a tool to convert/accelerate the import?


You should consider using the COPY command, the \copy meta-command of psql, or the pg_bulkload utility. Any of these should be significantly faster than the Ruby script you show, and have been well-tested for correct handling of line breaks and other odd characters within the data.