only connect to sql when querying