trinodb / trino-python-client

Python client for Trino
Apache License 2.0
328 stars 163 forks source link

Configure `experimental_python_types` through `connect`. #197

Closed tkorvola closed 2 years ago

tkorvola commented 2 years ago

Currently connection.cursor(experimental_python_types=True) is needed to enable support for, e.g., timestamps. It is against DBAPI for cursor to take parameters and SQLAlchemy does not seem to provide any means for passing them. I'd suggest moving the flag to connect, where database dependent parameters are allowed; in SQLAlchemy you'd pass them as connect_args to create_engine.

mdesmet commented 2 years ago

HI @tkorvola, thanks for raising this issue.

Could you refer me to where you found that this is against DBAPI. I don't seem to find that on https://peps.python.org/pep-0249/#cursor-objects

Could you maybe rename the issue to "Configure experimental_python_types parameter through the Connection object"? That way we are backwards compatible and also support the SQLAlchemy use case.

tkorvola commented 2 years ago

You can of course keep the current optional parameter of cursor. It is just not part of DBAPI, thus frameworks built on DBAPI can't be expected to support it. In contrast, they can be expected to support passing arbitrary parameters to connect.