4.14.3 Connecting with Python
You can connect to a remote graph server (PGX) instance in your Python program. You must first authenticate with the remote server before you can create a session as illustrated in the following example:
import pypgx as pgx
import opg4py.graph_server as graph_server
  
base_url = "https://localhost:7007"
username = "scott"
password = "<password-for-scott>"
 
instance = graph_server.get_instance(base_url, username, password)
session = instance.create_session("python_pgx_client")
print(session)To execute, save the above program into a file named
                                        program.py and run the following
                                command:
                  
python3 program.pyAfter successful login, you'll see the following message indicating a PGX session was created:
PgxSession(id: 0bdd4828-c3cc-4cef-92c8-0fcd105416f0, name: python_pgx_client)Note:
To view the complete set of available Python APIs, see OPG4PY Python API Reference.Parent topic: Connecting to the Graph Server (PGX)