How would someone go about accomplishing this goal?
To attach the cord of a lamp socket to a piece of plumbing pipe, you can
Use a hot glue gun to keep the cord flat and out of sight