Fix database handle passing and query params.