The left-back was without a club after his contract with the Edinburgh side expired at the end of last season.
Saints boss Danny Lennon told the club's website: "We lost a very good left back at the end of last season when Paul Dummett left to fight for a starting place at Newcastle United.
"Danny is a top quality left back to replace him. I have known Danny since he was a young lad at Gretna and he has gone on to prove himself to be a stand out player in the SPL.
"He has the ability, experience and character we are looking for to help take the club forward and we are delighted to have him on board."