Yes David wrote the Psalms and one of them comes from Moses. It was an oral tradition all those years until David recorded what was a oral tradition for years. It is interesting to see what the people say that give us our Bible. There are constant changes and revisions. Yet somehow everything remains intact. Lets look at what AI says about this.
The Torah is generally considered to have been compiled between 450–350 BCE, during the Persian period (539–332 BCE). This is based on evidence from early manuscripts and non-biblical sources, such as the Letter of Aristeas, which indicates that the Torah was translated into Greek in Alexandria around 285–247 BCE.
However, the Torah's traditional attribution to Moses, who is said to have received the text from God over 40 years, starting at Mount Sinai and ending in 1272 BCE, has led some to believe it was written much earlier. However, scholars say that only small portions of the Torah can be traced back to Moses, such as Exodus 17:14, 24:4, 34:28, Numbers 33:2, Deuteronomy 31:9, and 31:22. Others, known as minimalists, believe the Torah was written after the Israelites' captivity, around 1,000 years later than the traditional view.
Notice in the Hebrew Bible there are no sentences much less paragraphs and chapters. The Bible was intended to be read and the rhythm was memorized. Sort of like music where they record the lyrics but the music itself is memorized and not recorded.
View attachment 351677
		 
		
	 
Just a slight correction to my post, some of the Psalms were written by David, some by others, one by Moses.  Given that Moses is attributed to have written the first five books of scripture, there is no reason to suggest that he didn't write the one Psalm and it was simply organized later in with the rest of the Psalms.  He also wrote the song in Deuteronomy 31.  
I'm familiar with liberal scholars who claim the Torah was written much later.  What "scholars" states, I'm not overly impressed.  Usually these are like "unnamed sources" these days.  They are often liberal theologians who don't believe the Bible or simply seek to discredit the Word of God.
There is nothing to support a later date.  
1) 2 Kings 22 and 2 Chronicles 34 tells us the book of the Law was hidden for 60 years and later found by Hilkiah during the reign of Josiah around the year of 622BC, prior to going into captivity.  Thus, if the Torah wasn't written until 450-350BC as you claim, how would Hilkiah have possibly found the Book of the Law 200-300 years before it was even written?  
2) Specific details of the terrain and geographical markers are included that would have been lost on someone writing a century later especially if they no longer existed.  (e.g. Ex 15:27  there 
were twelve springs of water and seventy date 
palms, and they camped there beside the waters.)  
3) Moses was a highly intelligent, skilled individual.  Writing was part of his calling.  Acts 7:21 states "Moses was educated 
in all the learning of the Egyptians, and he was a man of power 
in words and deeds.  And again:  
Exodus 34:27 Then the Lord said to 
Moses, “
Write down these words, for in accordance with these words I have made a covenant with you and with Israel.”
4) There was NEVER any question in scripture that anyone believe Moses did not write the Torah.  It is repeated over and over in Scripture.  To name a few places:
John 5:46  For if you believed 
Moses, you would believe 
Me, for he 
wrote about Me.
 
Mark 12:26  But regarding the fact that the dead rise again, have you not read in the book of 
Moses, in the 
passage about 
the burning bush, how God spoke to him, saying, ‘I am the God of Abraham, and the God of Isaac, and the God of Jacob’?
 
Luke 20:28 and they questioned Him, saying, “Teacher, 
Moses wrote for us that if a man’s brother dies, having a wife, and he is childless, his brother should marry the wife and raise up children to his brother.
 
Luke 24:27 Then beginning with 
Moses and with all the prophets, He explained to them the things concerning Himself in all the Scriptures.
 
John 1:45  Philip *found Nathanael and *said to him, “We have found Him of whom 
Moses in the Law and 
also the Prophets wrote—Jesus of Nazareth, the son of Joseph.”
 
It's pretty clear from our Lord Jesus Christ that 
1) Moses wrote the first five books (since our Lord Jesus was talking to Jews in John 5:46), and
2) what Moses wrote was about Christ.
This is despite what the "scholars" states.