The verb "savoir" ('to know/know how to [do something]') is irregular in Le Présent tense:
Learn more about these related French grammar topics
Examples and resources
Q&A Forum 1 question, 2 answers
Connaitre ou Savoir
Having consulted with some French compatriots living in France, we do agree that 'savoir' here is the instinctive verb we would use in both the examples you quote.
However, it is true that 'connaître' would be acceptable but 'savoir' is better perhaps because of the 'par cœur' which indicate that you know the text and the lesson for sure...