Open database connection only during db operations to avoid possible timeout