What Actually Happens When You Connect to a Database?

As developers, we write database connection code all the time. Whether it's a single line like: