rows2dict

2024-07-28  本文已影响0人  hehehehe
cursor = conn.cursor(cursor_factory=DictCursor)
cursor.execute(sql)
rows = cursor.fetchall()
rows_dict = [dict(row) for row in rows]

            rows = session.execute(sql)
            keys = rows.keys()
            return [dict(zip(keys, row)) for row in rows]
import polars as pl
import pyarrow as pa


def rows2df(rows_dict):
    if rows_dict:
        return pl.from_dicts(rows_dict, infer_schema_length=len(rows_dict))
    return pl.DataFrame()


def rows2table(rows_dict):
    return pa.Table.from_pylist(rows_dict)
上一篇下一篇

猜你喜欢

热点阅读