If my Keepass database is ever compromised, I've got much bigger issues than leaked 2FA codes. There is even debate as to whether using 2FA substantially increases security. I have them because some apps & services just refuse to work well without them, and all agree they are better than SMS codes.
As far as Keepass security, I use master database password + locally stored key token + phone password + E2EE cloud storage. If someone managed to decrypt the cloud, steal the database, and steal my master database password, they would still need a key token. I sleep well at night.