“I give thanks to you.
Yahweh my God!
With my whole heart,
I will glorify your name forever.
Great is your steadfast love toward me.
You have delivered my soul
From the depths of Sheol.”
David gave thanks to Yahweh, his God. With his whole heart he wanted to glorify his name forever. Yahweh’s steadfast love towards him had delivered his soul from the depths of Sheol. It sounds like Yahweh saved David from death at some point because he loved him so much.