AnsweredAssumed Answered

How to set UID & password to connect to PI using python & AF SDK?

Question asked by Amir_rf on Jul 16, 2019
Latest reply on Jul 23, 2019 by Amir_rf

Do you know how to set UID & password to connect to PI using python & AF SDK?
This is my function, but it give error that piServer doesn`t have the "Open" method:

 

def connect_to_server(server_name='SERV1'):
    piServers = PIServers()
    if piServers.Contains(server_name):
        piServers.DefaultPIServer = piServers[server_name]; 
        piServer = piServers.DefaultPIServer
    else:
        piServer = piServers.Add(server_name)
        piServers.DefaultPIServer = piServers[server_name]; 
       
        piServer = piServers.DefaultPIServer
        if (server_name == 'SERV2'):
            piServer.Open("UID=USERNAME;PWD=PASSWORD")
           
    print('Server in use: {}'.format(server_name))
    return piServer

Outcomes