db_utils: Make connect_to_conninfo use through contextmanager
This allows to reduce the boilerplate regarding initial connection failures.