Update to take db object instead of connection