---
title: "GSQL Interface"
component: "pytigergraph"
version: "1.7"
module: "core-functions"
html_url: "/pytigergraph/1.7/core-functions/gsql"
canonical_url: "https://www.tigergraph.com/docs/pytigergraph/1.7/core-functions/gsql"
markdown_url: "https://www.tigergraph.com/docs/pytigergraph/1.7/core-functions/gsql.md"
---

[View as HTML](https://www.tigergraph.com/docs/pytigergraph/1.7/core-functions/gsql)

# GSQL Interface

Use GSQL within pyTigerGraph. All functions in this module are called as methods on a [TigerGraphConnection object](https://www.tigergraph.com/docs/pytigergraph/1.8/core-functions/base.md).

## gsql()

`gsql(query: str, graphname: str = None, options = None) → Union[str, dict]`

Runs a GSQL query and processes the output.

#### Parameters:

* `query`: The text of the query to run as one string. The query is one or more GSQL statement.
* `graphname`: The name of the graph to attach to. If not specified, the graph name provided at the time of establishing the connection will be used.
* `options`: DEPRECATED

#### Returns:

The output of the statement(s) executed.

#### Endpoint:

* `POST /gsqlserver/gsql/file` (In TigerGraph versions 3.x)
* `POST /gsql/v1/statements` (In TigerGraph versions 4.x)

## installUDF()

`installUDF(ExprFunctions: str = "", ExprUtil: str = "") → None`

Install user defined functions (UDF) to the database.  
See [this](https://www.tigergraph.com/docs/gsql-ref/4.3/querying/func/query-user-defined-functions.md) for more details. for details on UDFs.

#### Parameters:

* `ExprFunctions (str, optional)`: Path or URL to the file for ExprFunctions. Defaults to '' (a blank path/URL).
* `ExprUtil (str, optional)`: Path or URL to the file for ExprUtil. Defaults to '' (a blank path/URL).

#### Returns:

Status of the installation.

#### Endpoints:

* `PUT /gsqlserver/gsql/userdefinedfunction?filename={ExprFunctions or ExprUtil}"` (In TigerGraph versions 3.x)

## getUDF()

`getUDF(ExprFunctions: bool = True, ExprUtil: bool = True, json_out: bool = False) → Union[str, Tuple[str, str], Dict[str, str]]`

Get user defined functions (UDF) installed in the database.  
See [this](https://www.tigergraph.com/docs/gsql-ref/4.3/querying/func/query-user-defined-functions.md) for more details. for details on UDFs.

#### Parameters:

* `ExprFunctions (bool, optional)`: Whether to get ExprFunctions. Defaults to True.
* `ExprUtil (bool, optional)`: Whether to get ExprUtil. Defaults to True.
* `json_out (bool, optional)`: Whether to output as JSON. Defaults to False. Only supported on version >=4.1

#### Returns:

* `str`: If only one of `ExprFunctions` or `ExprUtil` is True and json\_out is False, return of the content of that file.
* `Tuple[str, str]`: If both `ExprFunctions` and `ExprUtil` are True and json\_out is False, return content of ExprFunctions and content of ExprUtil.
* `Dict[str, str]`: If json\_out is True, return dict with `ExprFunctions` and/or `ExprUtil` as keys and content of file as value.

#### Endpoints:

* `GET /gsqlserver/gsql/userdefinedfunction?filename={ExprFunctions or ExprUtil}` (In TigerGraph versions 3.x)
* `GET /gsql/v1/udt/files/{ExprFunctions or ExprUtil}` (In TigerGraph versions 4.x)
