0

according the doc in [url:https://pola-rs.github.io/polars-book/user-guide/howcani/io/read_db.html]

import polars as pl

conn = "postgres://username:password@server:port/database"
query = "SELECT * FROM foo"

pl.read_sql(query, conn)

---------------------------------------------------------------------------
PanicException                            Traceback (most recent call last)
Input In [120], in <module>
      1 import connectorx
----> 2 df = pl.read_sql(query, conn)

File e:\bokeh\venv\lib\site-packages\polars\io.py:969, in read_sql(sql, connection_uri, partition_on, partition_range, partition_num, protocol)
    903 """
    904 Read a SQL query into a DataFrame.
    905 Make sure to install connectorx>=0.2
   (...)
    966 
    967 """
    968 if _WITH_CX:
--> 969     tbl = cx.read_sql(
    970         conn=connection_uri,
    971         query=sql,
    972         return_type="arrow",
    973         partition_on=partition_on,
    974         partition_range=partition_range,
    975         partition_num=partition_num,
    976         protocol=protocol,
    977     )
    978     return from_arrow(tbl)  # type: ignore[return-value]
    979 else:

File e:\bokeh\venv\lib\site-packages\connectorx\__init__.py:151, in read_sql(conn, query, return_type, protocol, partition_on, partition_range, partition_num, index_col)
    148 except ModuleNotFoundError:
    149     raise ValueError("You need to install pyarrow first")
--> 151 result = _read_sql(
    152     conn,
    153     "arrow" if return_type in {"arrow", "polars"} else "arrow2",
    154     queries=queries,
    155     protocol=protocol,
    156     partition_query=partition_query,
    157 )
    158 df = reconstruct_arrow(result)
    159 if return_type == "polars":

**PanicException: called `Result::unwrap()` on an `Err` value: Error { kind: ConfigParse, cause: Some("unexpected EOF") }**

Postgresql is 14.2, OS is Windows 10. The postgresql server is running well, I can psql database username in cmd.

According to the doc, I pip install pyarrow, connectorx.

Hengaini
  • 44
  • 5
  • Can you run the command with `RUST_BACKTRACE=1`? This will give you a backtrace of the panic. And can you open an issue [here](https://github.com/pola-rs/polars/issues). This should not be handled on SO. – ritchie46 Mar 11 '22 at 07:59
  • Ok! I rerun and open an issue in polars github. – Hengaini Mar 12 '22 at 01:02

0 Answers0