pytigergraph/ Core Functions
Last Updated: October 20, 2018

Executing data operations and query management in Python.

Core Functions

Once a connection is established, the TigerGraphConnection object provides methods to interact with every layer of the database.

1. Data Manipulation

Retrieve, insert, or delete graph elements without writing GSQL.

pythonterminal
# Fetch vertices of a specific type vertices = conn.getVertices("Person", limit=100) # Upsert data from a dictionary conn.upsertVertex("Person", "p1", attributes={"name": "Alice", "age": 30}) # Fetch edges between two vertices edges = conn.getEdges("Person", "p1", edgeType="FRIEND")

2. Query Execution

Run pre-installed GSQL queries and receive results as JSON or DataFrames.

pythonterminal
# Run a query with parameters results = conn.runInstalledQuery("find_friends", params={"min_age": 21}) # Output results as a Pandas DataFrame import pandas as pd df = pd.DataFrame(results[0]["f"])

3. Schema Management

Inspect and modify the graph structure programmatically.

pythonterminal
# Get the full schema as a JSON object schema = conn.getSchema() # Get a list of vertex types v_types = conn.getVertexTypes()

4. GSQL Interface

For tasks that require raw GSQL, pyTigerGraph can execute strings directly on the GSQL shell.

pythonterminal
output = conn.gsql("ls") print(output)

[!NOTE] All core functions handle the underlying REST endpoint logic (ports 14240 and 9000) automatically, so you don't have to manage complex URL strings.