【问题标题】:Adding stream_results=True (execution_options) to kedro.extras.datasets.pandas.SQLQueryDataSet将 stream_results=True (execution_options) 添加到 kedro.extras.datasets.pandas.SQLQueryDataSet
【发布时间】:2021-04-20 15:58:25
【问题描述】:

是否可以将 execution_options 添加到 kedro.extras.datasets.pandas.SQLQueryDataSet 中?

例如,我想将 stream_results=True 添加到连接字符串中。

engine = create_engine( “postgresql://postgres:pass@localhost/example” ) conn = engine.connect().execution_options(stream_results=True)

这是我的目录.yml

table_name:
  type: pandas.SQLQueryDataSet
  credentials: creds
  sql: select * from table
  load_args:
    chunksize: 1000

关于如何使用 pandas.SQLQueryDataSet 添加/编辑 execution_options 的任何想法? 具体来说,stream_results=True。

【问题讨论】:

    标签: pandas sqlalchemy kedro


    【解决方案1】:

    您可能需要在现有的SQLQueryDataSet 上创建一个薄层:

    class CustomSQLQueryDataSet(kedro.extras.datasets.SQLQueryDataSet):
      def _load(self, *args, **kwargs):
          self._load_args["con"] = create_engine(self._load_args["con"]).connect().execution_options(stream_results=True)
          return super()._load(*args, **kwargs)
    

    然后在你的目录中使用这个类。

    【讨论】:

      猜你喜欢
      • 2017-06-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-29
      • 2021-10-23
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多