trinodb / trino-python-client

Python client for Trino
Apache License 2.0
311 stars 154 forks source link

Configure `experimental_python_types` through `dbapi.Connection` #198

Closed mdesmet closed 2 years ago

mdesmet commented 2 years ago

Fixes #197

mdesmet commented 2 years ago

While testing the sqlalchemy feature, I found a bug in the experimental_python_types implementation. If there is a row coming back from the first POST request, this row would not be mapped using the experimental_python_types logic. I didn't encounter this behaviour before and this was also not detected in the integration tests.

from sqlalchemy import create_engine
from sqlalchemy.schema import Table, MetaData
from sqlalchemy.sql.expression import select, text

engine = create_engine('trino://user@localhost:8080/system?experimental_python_types=true')
connection = engine.connect()

print(connection.execute(text("SELECT DECIMAL '1.2355'")).fetchall())
ebyhr commented 2 years ago

Merged, thanks!