E.g. using a super dodgy query on the internal db...
tagPath = 'Tag/Path'
# get the tag provider in the local gateway from the config in case the tag provider wasn't provided in the path
tagProvider = system.tag.getConfiguration(tagPath)[0]['path'].split(']')[-1]
context = system.util.getContext()
session = context.getPersistenceInterface().getSession()
try:
query = """
SELECT
COALESCE(gtps.PROVIDERNAME, tps.NAME) as tag_provider,
gtps.HISTORYDRIVERNAME as gateway_name
FROM
TAGPROVIDERSETTINGS tps
LEFT JOIN GANTAGPROVIDERSETTINGS gtps ON gtps.PROFILEID = tps.TAGPROVIDERSETTINGS_ID
WHERE tps.name = '{}'
""".format(tagProvider)
rt = session.rawQueryMaps(query, True, []) # sql, flush, params
finally:
session.close()
rt = rt[0]
histProvider, gatewayName = [qval.value for qval in system.tag.readBlocking([
'{}.historyProvider'.format(tagPath),
'[System]Gateway/SystemName'])]
gatewayName = gatewayName or rt['gateway_name']
tagProvider = rt['tag_provider']
tagPath = tagPath.split(']')[-1]
system.perspective.print('histProvider: {}'.format(histProvider))
system.perspective.print('gatewayName: {}'.format(gatewayName))
system.perspective.print('tagProvider: {}'.format(tagProvider))
system.perspective.print('tagPath: {}'.format(tagPath))