fixed SQL_writer to batch write

Much faster!