simple function to query sqlite db and return json