Ranked the 141st-best professional prospect by Baseball America, he chose to attend Vanderbilt University, where he played college baseball for the Commodores in the Southeastern Conference (SEC) of the National Collegiate Athletic Association's Division I alongside fellow future Major League players David Price and Pedro Alvarez; the latter became a teammate on the Baltimore Orioles in 2016.
Flaherty became the seventh position player to make a pitching appearance in Orioles history in a 12–2 loss to the Houston Astros at Camden Yards on August 20, 2016. He had entered the game as a third baseman in the eighth inning. Throwing 19 pitches in the ninth, he surrendered two earned runs and three hits on a leadoff homer by Jason Castro and consecutive one-out doubles from George Springer and Alex Bregman.
Flaherty married Ashley Dutko, the sister of Nick Markakis' wife Christina Dutko, in 2016.