Fix queries using a different connection

@wesokes