Keepassxc has been perfect for this. A clean UI allows humans to navigate if needed, and keepassxc.cli provides enough surface to let a script generate a .env file as part of a bootstrap or disaster recovery process.
EDIT: Apparently they're rebranding to KeePass Hub.