Electrolysis was a popular idea for [how mermaids would generate oxygen for their guests](https://worldbuilding.stackexchange.com/questions/192698/how-would-mermaids-collect-oxygen-for-their-underwater-cities). This leads to another question: Is it possible to perform electrolysis with pre-modern technology?

Electrolysis was apparently first performed in the 19th century, though not as an intentional electrolysis experiment. From what I understood of the process, it seemed possible, as there are some electrical experiments back in history, and it appeared that electrolysis only requires power, a solution, and two electrodes?

But is this actually the case? Could medieval people, or a fictional people with medieval or earlier technology, have performed electrolysis, and collected and separated samples from this process (specifically oxygen and hydrogen)?

Additionally, if it's not too much to ask, I would ask when in history this first could have become possible.