If you see "NNUE" on the end of Stockfish's name, it means it's using something called a neural network (i.e. "Stockfish 15.1 NNUE"). A neural network works in a similar fashion to how your brain does. For example, you can look at an easy chess puzzle (say, a simple knight fork), and immediately know the right move. You don't have to check that the knight is attacking your opponent's king and rook, or that it is moving to a safe square. You know that it wins the exchange. Or, a better explanation might be the common description of Jose Raul Capablanca's abilities---many said that he could take one glance at a chessboard and know what the position needed.
That's a pretty simple explanation of how a neural network functions. Stockfish trains its neural network by playing millions of games with itself, and with each game the network gets a tiny bit better at evaluating positions. Then in an actual game or evaluation, it uses the network alongside traditional engine calculation to provide more accurate positional play (pawn structures and piece placement are what are really affected by neural network evaluation).
So the answer is yes and no. Stockfish doesn't reference a game database when it plays, but it does use a neural network that essentially makes it learn from its mistakes during self-play.