Do not connect to the database unless necessary