In Python this can be done as follows:
Using the python-chess module, iterate through the games in your pgn database. Docs: https://python-chess.readthedocs.io/en/latest/pgn.html
https://python-chess.readthedocs.io/en/latest/core.html#board
Now to use Stockfish, download the Stockfish engine, and then use the stockfish python module: https://pypi.org/project/stockfish/. python-chess can also be used to interact with Stockfish, but I'm not familiar myself with how to do this.
For each position in a game (that you want to find the best move for), get its FEN (using python-chess), and then set the stockfish module object's position to it (using the set_fen_position method). Finally, you can call the get_best_move
function of the stockfish module.