How to get templates from hosts list

Hello. I need to get host templates using hostnames. Hostnames I got using SQL. I tried to use the Icinga MySQL database but didn’t find any tables with templates. Can anybody help me?

do you use icinga director?

Yes. But If you have few solutions, it will be great.

try that:

curl -H "Accept: application/json" -u webuser:password "https://icinga-master/icingaweb2/director/hosts"

or that on the director database:

select a.object_name, b.object_name as template from icinga_host_inheritance 
join icinga_host a on host_id = a.id 
join icinga_host b on parent_host_id=b.id 
where b.object_type= "template" and  a.object_type = "object";

Thank you so much. Your query was recipe for me.

select distinct b.object_name as template from icinga_host_inheritance join icinga_host a on host_id = a.id join icinga_host b on parent_host_id=b.id where b.object_type= "template" and a.object_type = "object" and a.object_name in (select alias from icinga2idomysql.icinga_hosts where host_object_id in (select host_object_id from icinga2idomysql.icinga_hostgroup_members where hostgroup_id = 5)) order by template asc;