Is it safe for me to attach a ceiling light fixture to a wall socket?
I attached it by stripping an extension cord and wire-nutting the ends
of the fixture to the ends of the cord. Is there any reason to think that
this will cause a fire, assuming I insulate the connection well?
And, do I need to use the grounding wire?
It sounds like you are doing something like a swag light. Is that correct? I’m not too thrilled with the wire nut solution. If you had a solid wire from fixture to wall, it would be somewhat better.
I also hope you used a good quality extension cord, not the 99 cent ones. The wire is too small and the insulation too weak.
Code says it should be grounded. We didn’t ground fixtures for a lot of decades and there were few problems. There were enough that they added grounding to the code, but it certainly isn’t the most common problem in the world.
Bottom line, grounded is code, grounded is safer, ungrounded is okay 9999 times out of 10000. You add up the risks.