move db and name above query