Skip to main content

Library to connect to TigerGraph databases

Project description

Getting Started

To download pyTigerGraph, simply run: pip install pyTigerGraph Once the package installs, we can import it and instantiate a connection to your database:

import pyTigerGraph as tg

conn = tg.TigerGraphConnection(ipAddress="YOUR_URL_HERE", graphname="YOUR_GRAPH_NAME", username="YOUR_USERNAME", password="YOUR_PASSWORD", apiToken="YOUR_API_TOKEN_HERE")

There are a few more options when instantiating the connection that aren't in the example above. They are:

  • apiPort (default 9000): This should be changed if your server has been configured to use a different port for the REST++ endpoint service that TigerGraph provides
  • interpreterPort (default 14240): This should be changed if your server has been configured to use a different port for GraphStudio

The username and password default to the TigerGraph default username and password, which is tigergraph. The API token can be obtained via the method described below.

The Methods

Once you have the package installed and the connection instantiated, you are all set to use the provided methods. There are currently only three methods, but more are on the way.

getToken("SECRET", "LIFETIME")

This method gets an API token given a secret key and the desired lifetime of the token, in seconds. When instantiating a connection to use this method, simply leave the apiToken field blank, so it looks like this:

import pyTigerGraph as tg

conn = tg.TigerGraphConnection(ipAddress="YOUR_URL_HERE", graphname="YOUR_GRAPH_NAME", username="YOUR_USERNAME", password="YOUR_PASSWORD")

print(conn.getToken("YOUR_SECRET_HERE", "1000000")) #uses a lifetime of 1,000,000 seconds

runInstalledQuery("queryName", {params}, timeout, sizeLimit)

This method runs a query installed on the database and returns the JSON response. The query name is a string and then a dictionary of parameters. Once you instantiate a connection, the code looks something like this:

params = {"vid":"Jazz", "vid.type":"Article"} #query's arguments
queryName = "getKeywords"

preInstalledResult = conn.runInstalledQuery(queryName, params) 

print(preInstalledResult)

The timeout and sizeLimit parameters are optional, and should be passed in as integers. The default timeout is 16 seconds and the default sizeLimit is 320000 bytes.

getEndpoints()

This method returns a JSON response of all possible endpoints on the server. To run, simply:

endpoints = conn.getEndpoints()

print(endpoints)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyTigerGraph-0.0.4.7.3.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

pyTigerGraph-0.0.4.7.3-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page