Skip to content

Wrong host parsing from toml connection config using Trino #1057

@jjak0b

Description

@jjak0b

What happens?

Description of the problem

What i'm trying to do:

Use a connection using trino python through a connection string

%sql trino://https://trino-coordinator:8443/mycatalog/myschema?verify=false

o in equivalent way using toml connection configuration

[myConnection]
drivername = trino
host = https://trino-coordinator
port = 8443
database = mycatalog/myschema
query = { "verify": "false" }

But i'm getting the following error:

UsageError: An error happened while creating the connection: invalid literal for int() with base 10: 'trino-coordinator:8443'.

To fix it:

Pass a valid connection string:
    Example: %sql postgresql://username:password@hostname/dbname

For more details, see: https://jupysql.ploomber.io/en/latest/connecting.html

Cause of the issue

I think the issue is caused by the use of the schema used in the host component parsed by JupySQL

The following connection configuration works

%sql trino://trino-coordinator:8080/mycatalog/myschema

or

[myConnection]
drivername = trino
host = trino-coordinator
port = 8443
database = mycatalog/myschema
query = { "verify": "false" }

(i'm omitting credentials)

Connection is created but trino dbapi implementation instance it based on the the schema of host component by default using urllib.parse.urlparse or using http if not provided.

In my use case i need to use https since i pass also access_token and other query parameters to trino.

To Reproduce

%sql trino://https://trino-coordinator:8443/mycatalog/myschema?verify=false

o in equivalent way using toml connection configuration

[myConnection]
drivername = trino
host = https://trino-coordinator
port = 8443
database = mycatalog/myschema
query = { "verify": "false" }

OS:

Linux

JupySQL Version:

0.11.1

Full Name:

Jacopo Rimediotti

Affiliation:

Iconsulting

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions