API Reference#

PIconnect - Connector to the OSISoft PI and PI-AF databases.

class PIconnect.AFDatabase(server: str | None = None, database: str | None = None)#

Bases: object

Context manager for connections to the PI Asset Framework database.

classmethod default_server() PISystem | None#

Return the default server.

classmethod servers() dict[str, PISystem]#

Return a dictionary of the known servers.

descendant(path: str) AFElement#

Return a descendant of the database from an exact path.

event_frames(start_time: str | datetime = '', start_index: int = 0, max_count: int = 1000, search_mode: EventFrameSearchMode = EventFrameSearchMode.FORWARD_FROM_START_TIME, search_full_hierarchy: bool = False) dict[str, AFEventFrame]#

Search for event frames in the database.

property children: dict[str, AFElement]#

Return a dictionary of the direct child elements of the database.

database#

The PI AF database connection.

property database_name: str#

Return the name of the connected PI AF database.

search: Search#

Search reference for searching objects in the database. See Search.Search for more information.

server#

The PI AF server connection.

property server_name: str#

Return the name of the connected PI AF server.

property tables: dict[str, AFTable]#

Return a dictionary of the tables in the database.

version = '0.3.0'#
class PIconnect.PIAFDatabase(server: str | None = None, database: str | None = None)#

Bases: AFDatabase

Context manager for connections to the PI Asset Framework database.

Deprecated since version 1.0.0: Use AFDatabase instead.

classmethod default_server() PISystem | None#

Return the default server.

classmethod servers() dict[str, PISystem]#

Return a dictionary of the known servers.

descendant(path: str) AFElement#

Return a descendant of the database from an exact path.

event_frames(start_time: str | datetime = '', start_index: int = 0, max_count: int = 1000, search_mode: EventFrameSearchMode = EventFrameSearchMode.FORWARD_FROM_START_TIME, search_full_hierarchy: bool = False) dict[str, AFEventFrame]#

Search for event frames in the database.

property children: dict[str, AFElement]#

Return a dictionary of the direct child elements of the database.

database#

The PI AF database connection.

property database_name: str#

Return the name of the connected PI AF database.

search: Search#

Search reference for searching objects in the database. See Search.Search for more information.

server#

The PI AF server connection.

property server_name: str#

Return the name of the connected PI AF server.

property tables: dict[str, AFTable]#

Return a dictionary of the tables in the database.

version = '0.3.0'#
class PIconnect.PIServer(server: str | None = None, username: str | None = None, password: str | None = None, domain: str | None = None, authentication_mode: AuthenticationMode = AuthenticationMode.PI_USER_AUTHENTICATION, timeout: int | None = None)#

Bases: object

PIServer is a connection to an OSIsoft PI Server.

Parameters:
  • server (str, optional) – Name of the server to connect to, defaults to None

  • username (str, optional) – Username to connect to the server, defaults to None

  • password (str, optional) – Password for the username, defaults to None

  • domain (str, optional) – Domain of the username, defaults to None

  • authentication_mode (AuthenticationMode, optional) – Authentication mode to use, defaults to PI_USER_AUTHENTICATION

  • timeout (int, optional) – the maximum seconds an operation can take

Note

If the specified server is unknown a warning is thrown and the connection is redirected to the default server, as if no server was passed. The list of known servers is available in the PIServer.servers dictionary.

classmethod default_server() PIServer | None#

Return the default server.

classmethod servers() dict[str, PIServer]#

Return a dictionary of the known servers.

search(query: str | list[str], source: str | None = None) DataContainerCollection[PIPoint]#

Search PIPoints on the PIServer.

Parameters:
  • query (str or [str]) – String or list of strings with queries

  • source (str, optional) – Defaults to None. Point source to limit the results

Returns:

A collection of PIPoint objects as a result of the query.

Return type:

Data.DataContainerCollection[PIPoint]

Todo

Reject searches while not connected

property server_name#

Name of the connected server.

PIconnect.load_SDK(assembly_path: str | Path | None = None) None#

Load the AF SDK from the specified path.

Parameters:

assembly_path (str | pathlib.Path, optional) – Path to the directory containing the AF SDK assembly. If None, the default installation path will be used.

Raises:

ImportError – If the AF SDK cannot be found or loaded.

Generic utility modules#