How can I access the contents of platformio.ini from my custom script?

I’m trying to teach my extension script to select the files to compile, based on some database contents.
That’s not the problem; the problem is that I’d like to store the database parameters in platformio.ini.

So how do I access the current configuration from my extension script? The example in the documentation says to import configparser and to load it myself, which seems suboptimal because (a) it’s duplicate work, (b) pio has a nice option to load a different config file, or even multiple config files, which starts to look less and less like a viable solution.

Thanks, documentation has been updated!