Wouldn't a result of pg_dump (with --inserts --no-owner and --no-priveleges) almost work? It should be just an SQL script with all the CREATE statements and INSERTs for data.
Granted, CREATEs are not going to be perfect -- some tweaking may be required.