Error: The attempt to query the database when not connected