diff --git a/trino/dbapi.py b/trino/dbapi.py index 5d0ae358..8adc4d18 100644 --- a/trino/dbapi.py +++ b/trino/dbapi.py @@ -294,22 +294,13 @@ def warnings(self): return self._query.warnings return None - def _new_request_with_session_from(self, request): - """ - Returns a new request with the `ClientSession` set to the one from the - given request. - """ - request = self.connection._create_request() - request._client_session = request._client_session - return request - def setinputsizes(self, sizes): raise trino.exceptions.NotSupportedError def setoutputsize(self, size, column): raise trino.exceptions.NotSupportedError - def _prepare_statement(self, statement, name): + def _prepare_statement(self, statement: str, name: str) -> None: """ Registers a prepared statement for the provided `operation` with the `name` assigned to it. @@ -318,8 +309,7 @@ def _prepare_statement(self, statement, name): :param name: name that will be assigned to the prepared statement. """ sql = f"PREPARE {name} FROM {statement}" - # TODO: Evaluate whether we can avoid the piggybacking on current request - query = trino.client.TrinoQuery(self._new_request_with_session_from(self._request), sql=sql, + query = trino.client.TrinoQuery(self.connection._create_request(), sql=sql, experimental_python_types=self._experimental_pyton_types) query.execute() @@ -404,10 +394,9 @@ def _format_prepared_param(self, param): raise trino.exceptions.NotSupportedError("Query parameter of type '%s' is not supported." % type(param)) - def _deallocate_prepared_statement(self, statement_name): + def _deallocate_prepared_statement(self, statement_name: str) -> None: sql = 'DEALLOCATE PREPARE ' + statement_name - # TODO: Evaluate whether we can avoid the piggybacking on current request - query = trino.client.TrinoQuery(self._new_request_with_session_from(self._request), sql=sql, + query = trino.client.TrinoQuery(self.connection._create_request(), sql=sql, experimental_python_types=self._experimental_pyton_types) query.execute()