connect and query