# How to Query Trino via REST python client?

**URL:** <https://discourse.julialang.org/t/how-to-query-trino-via-rest-python-client/98832>\
**Category:** General Usage\
**Tags:** question, pycall\
**Created:** [May 14, 2023, 11:56am UTC](https://discourse.julialang.org/t/how-to-query-trino-via-rest-python-client/98832 "2023-05-14T11:56:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![EMCP](https://avatars.discourse-cdn.com/v4/letter/e/db5fbb/32.png) [@EMCP](https://discourse.julialang.org/u/EMCP)\
**Post date:** [May 14, 2023, 11:56am UTC](https://discourse.julialang.org/t/how-to-query-trino-via-rest-python-client/98832/1 "2023-05-14T11:56:05Z")

</div>

I have a trino cluster, which I am just wanting to query in Julia … get things into a few nice Table.jl tables and do some work with each dataset… but having trouble getting connected … the raw REST api is undocumented unfortunately and I’d like to leverage the python library if/where possible instead of writing my own… but PyCall seems to not support `from` statements… ?

here’s my code , i tried using the conda package but got an error … so have manually installed trino to the system instead

```julia
using PyCall

trino_lib = pyimport("trino")

py"""
from trino.dbapi import connect

def execute_query(input_statement):
    conn = connect(host="stonks-trino",port=8080, user="hive", catalog="hive",schema="hive")

    cur = conn.cursor()
    cur.execute(input_statement)
    return cur.fetchall()
"""

rows = py"execute_query"("SELECT * FROM hive.stonks.ibtickers")

print(rows)

```

I am having trouble knowing if this is the right avenue… do I define a custom function in python and give say the query via that function ? Never called Python from Julia before so just unclear how best to “wrap” the trino client elegantly

thanks

EDIT: found this link and have a somewhat working function… editing the statement to reflect the latest

EDIT2: I got back a matrix , now just looking how to get it into Tables.jl… but I am pleasantly surprised how easy this worked apart from Conda crashing

```julia
1409573×7 Matrix{Any}:
 SOME_DATA_REDACTED
 ⋮ ⋮           
 MORE_DATA_REDACTED

```

Now reading the [Home · Tables.jl](https://tables.juliadata.org/stable/#Tables.jl-Documentation) and trying to find how to put this matrix into a table as elegantly as possible

EDIT3:

Ah okay after seeing [Difference between Tables.jl and DataFrames.jl](https://discourse.julialang.org/t/difference-between-tables-jl-and-dataframes-jl/29944) , I understand what I really want is not Tables.jl but it’s dataframe implementation [Getting Started · DataFrames.jl](https://dataframes.juliadata.org/stable/man/getting_started/)

I think this is solved now…

---

<div class="post-metadata">

**Author:** ![Emiller](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emiller/32/33727_2.png) [@Emiller](https://discourse.julialang.org/u/Emiller)\
**Post date:** [July 28, 2023, 2:29pm UTC](https://discourse.julialang.org/t/how-to-query-trino-via-rest-python-client/98832/2 "2023-07-28T14:29:46Z")

</div>

You can also connect using [Home · ODBC.jl](https://odbc.juliadatabases.org/dev) and [JDBC.jl by JuliaDB](https://juliadatabases.org/JDBC.jl)!
