gsql_client
Introduction
If you are using TigerGraph, you probably know that there are only one way to remotely execute your GSQL scripts: gql_client.jar. This jar is an interactive console and you can not programmatically access GSQL server (until 2.4 TigerGraph introduces JDBC based access). But we love Python, right?
So here we are: a Python version of gsql_client, removing all interactive features. gsql_client.jar actually uses http to interact with GSQL server. So can Python. TigerGraph already open sourced their client implementation, but only for versions later than 2.3.0. I originally wrote this for 2.2.3, so there are minor differences.
Installation
Copy gsql_client folder to your project or install with pip:
pip install gsql_client
This package has no external dependency and it is compatible with both Python 2 and 3.
Note:
if you submit large gsql files or long running commands, using remote client may receive IncompleteRead exception as TigerGraph nginx service does not properly configure the
proxy_read_timeoutfor/gsqlserverpath. So you may need to edit{TIGERGRAPH_HOME}/tigergraph/config/nginx/nginx_1.confand add this option (like for/admin/websocketor/websocket).
TODO
Maybe I could create a main function to launch an interactive shell (using stdlib cmd module), so that
we can use python -m gsql_client just as java -jar gsql_client.jar. It is best to keep them compatible
(for both command line options and behaviors).
Usage
It contains mainly 2 classes: gsql_client.Client as a remote GSQL server client and gsql_client.RESTPP for directly interact with RESTPP server.
from gsql_client import Client, RESTPP
# default port 14240, you can use 10.0.0.1:29383 to specify another port
client = Client("10.0.0.1")
# for versions later than 2.4.0, it is mandatory to specify the version like this:
client = Client("10.0.0.1", version="v2_4_0")
# or the login would fail with incompatible server/client version
# you can directly specify the commit hash of the client (used for compatibility check) by:
client = Client("10.0.0.1", version="v2_6_0", commit="somehexhashstring")
client.login() # returns True for success; exceptions and False for failure
res = client.command("ls") # also returns the result as a list of lines
client.command("clear graph store", "y") # needs answer
client.run_file("yourfile.gsql")
client.version()
client.help()
client.quit()
restpp = RESTPP("10.0.0.1") # default port 9000
# no need to login
# but you can use restpp.requesttoken(secret) to setup token based authentication:
secret = client.get_secret("my_graph", create_alias="my_graph_query_secret")
# use=True for directly using the requested token
token = restpp.request_token(secret, use=True)
# or with set_token
restpp.set_token(token)
# same as type `select * from MyVertex` in gsql shell
restpp.select_vertices("my_graph", "MyVertex")
restpp.query("my_graph", "my_query", param1 = 1) # run your query
Metadata
Release files for gsql-client 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gsql_client-0.1.6.tar.gz | 13.6 kB | Without provenance | Details for gsql_client-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gsql_client-0.1.6-py2-none-any.whl | Python 2 | none | any | Details for gsql_client-0.1.6-py2-none-any.whl |
Total release size: 29.7 kB
Release files / gsql_client-0.1.6.tar.gz
| Download URL | gsql_client-0.1.6.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12643d5b8cb2b2de91a7799a8d5f9e7ba572193e7b96c1e983daaad96e9e7411
|
|
BLAKE2b-256 checksum How to use checksums |
1449f13cf4f66936e005855907d90af830ff40a954476ae2862abc49961f4bcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5
|
Release files / gsql_client-0.1.6-py2-none-any.whl
| Download URL | gsql_client-0.1.6-py2-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
2ccfcb9910f4d341604838ced9ce8e9ce248782c624f5b0be29f2c70d3a72cb7
|
|
BLAKE2b-256 checksum How to use checksums |
3fce01b47ca5d39dd378e7737fa6e7f84d1a0521df2ee7d2b8838c984be28b0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5
|
Security for gsql-client 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.