Trino

https://trino.io

Warning

This backend is experimental and is subject to backwards incompatible changes.

Install

Install Ibis and dependencies for the Trino backend:

Install with the trino extra:

pip install 'ibis-framework[trino]'

And connect:

import ibis

con = ibis.trino.connect()
1
Adjust connection parameters as needed.

Install for Trino:

conda install -c conda-forge ibis-trino

And connect:

import ibis

con = ibis.trino.connect()
1
Adjust connection parameters as needed.

Install for Trino:

mamba install -c conda-forge ibis-trino

And connect:

import ibis

con = ibis.trino.connect()
1
Adjust connection parameters as needed.

Connect

ibis.trino.connect

con = ibis.trino.connect(
    user="user",
    password="password",
    port=8080,
    database="database",
    schema="default",
)
Note

ibis.trino.connect is a thin wrapper around ibis.backends.trino.Backend.do_connect.”

Connection Parameters

do_connect

do_connect(self, user='user', password=None, host='localhost', port=8080, database=None, schema=None, source=None, **connect_args)

Connect to Trino.

Parameters
Name Type Description Default
user str Username to connect with 'user'
password str | None Password to connect with None
host str Hostname of the Trino server 'localhost'
port int Port of the Trino server 8080
database str | None Catalog to use on the Trino server None
schema str | None Schema to use on the Trino server None
source str | None Application name passed to Trino None
connect_args Additional keyword arguments passed directly to SQLAlchemy’s create_engine {}
Examples
>>> catalog = "hive"
>>> schema = "default"

Connect using a URL, with the default user, password, host and port

>>> con = ibis.connect(f"trino:///{catalog}/{schema}")

Connect using a URL

>>> con = ibis.connect(f"trino://user:password@host:port/{catalog}/{schema}")

Connect using keyword arguments

>>> con = ibis.trino.connect(database=catalog, schema=schema)
>>> con = ibis.trino.connect(database=catalog, schema=schema, source="my-app")

trino.Backend

create_schema

create_schema(self, name, database=None, force=False)

Create a schema named name in database.

Parameters

Name Type Description Default
name str Name of the schema to create. required
database str | None Name of the database in which to create the schema. If None, the current database is used. None
force bool If False, an exception is raised if the schema exists. False

create_table

create_table(self, name, obj=None, *, schema=None, database=None, temp=False, overwrite=False, comment=None, properties=None)

Create a table in Trino.

Parameters

Name Type Description Default
name str Name of the table to create required
obj pd.DataFrame | pa.Table | ir.Table | None The data with which to populate the table; optional, but one of obj or schema must be specified None
schema sch.Schema | None The schema of the table to create; optional, but one of obj or schema must be specified None
database str | None Not yet implemented. None
temp bool This parameter is not yet supported in the Trino backend, because Trino doesn’t implement temporary tables False
overwrite bool If True, replace the table if it already exists, otherwise fail if the table exists False
comment str | None Add a comment to the table None
properties Mapping[str, Any] | None Table properties to set on creation None

drop_schema

drop_schema(self, name, database=None, force=False)

Drop the schema with name in database.

Parameters

Name Type Description Default
name str Name of the schema to drop. required
database str | None Name of the database to drop the schema from. If None, the current database is used. None
force bool If False, an exception is raised if the schema does not exist. False

list_databases

list_databases(self, like=None)

List existing databases in the current connection.

Parameters

Name Type Description Default
like str | None A pattern in Python’s regex format to filter returned database names. None

Returns

Type Description
list[str] The database names that exist in the current connection, that match the like pattern if provided.

list_schemas

list_schemas(self, like=None, database=None)

list_tables

list_tables(self, like=None, database=None)

Back to top