pytigergraph/ Core Functions
Last Updated: October 20, 2018Executing 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.
pythonterminaloutput = 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.
On this page
- Core Functions
- 1. Data Manipulation
- Fetch vertices of a specific type
- Upsert data from a dictionary
- Fetch edges between two vertices
- 2. Query Execution
- Run a query with parameters
- Output results as a Pandas DataFrame
- 3. Schema Management
- Get the full schema as a JSON object
- Get a list of vertex types
- 4. GSQL Interface
TigerGraph Book
v1.0 Curated