How to Query Trino via REST python client?

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

using PyCall

trino_lib = pyimport("trino")

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()
    return cur.fetchall()

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


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


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

1409573×7 Matrix{Any}:
 ⋮                                              ⋮           

Now reading the Home · Tables.jl and trying to find how to put this matrix into a table as elegantly as possible


Ah okay after seeing Difference between Tables.jl and DataFrames.jl , I understand what I really want is not Tables.jl but it’s dataframe implementation Getting Started · DataFrames.jl

I think this is solved now…

You can also connect using Home · ODBC.jl and JDBC.jl by JuliaDB!