class_docstr: Abstraction for querying databases with user-supplied connection objects.
class_docstr_tok: ["Abstraction","for","querying","databases","with","user-supplied","connection","objects","."]
docstr: Convert the result set to a DataFrame.
  
  Wherever possible we try to return arrow-native data directly; only
  fall back to initialising with row-level data if no other option.
docstr_tok: ["Convert","the","result","set","to","a","DataFrame",".","Wherever","possible","we","try","to","return","arrow-native","data","directly",";","only","fall","back","to","initialising","with","row-level","data","if","no","other","option","."]
code: def to_polars(
      self,
      *,
      iter_batches: bool = False,
      batch_size: int | None = None,
      schema_overrides: SchemaDict | None = None,
  ) -> DataFrame | Iterable[DataFrame]:
      """
      Convert the result set to a DataFrame.
  
      Wherever possible we try to return arrow-native data directly; only
      fall back to initialising with row-level data if no other option.
      """
      if self.result is None:
          raise RuntimeError(
              "Cannot return a frame before executing a query"
          )
      elif iter_batches and not batch_size:
          raise ValueError(
              "Cannot set `iter_batches` without also setting a non-zero `batch_size`"
          )
  
      for frame_init in (
          self._from_arrow,  # init from arrow-native data (where support exists)
          self._from_rows,  # row-wise fallback (sqlalchemy, dbapi2, pyodbc, etc)
      ):
          frame = frame_init(
              batch_size=batch_size,
              iter_batches=iter_batches,
              schema_overrides=schema_overrides,
          )
          if frame is not None:
              return frame
  
      raise NotImplementedError(
          f"Currently no support for {self.driver_name!r} connection {self.cursor!r}"
      )
  
imports: from __future__ import annotations
  import re
  import sys
  from importlib import import_module
  from inspect import Parameter, signature
  from typing import TYPE_CHECKING, Any, Iterable, Literal, Sequence, TypedDict, overload
  from polars.convert import from_arrow
  from polars.exceptions import InvalidOperationError, UnsuitableSQLError
  from polars.utils.deprecation import issue_deprecation_warning
label_desc: Use image node_id 12 for calling the ConnectionExecutor obj's underlying member method code with example usage: obj.to_polars() and returns: frame