Failed to use Python API to query a table with a DECIMAL column

36 views Asked by At
  • DDB server version: 2.00.9.1 2023.02.20 ; linux64

  • python3.7

  • dolphindb package version : 1.30.21.1

My question is:

A column in the table is of type DECIMAL. When I query it with Python API, the error "Failed to read response header from the socket with IO error type 1" is reported. Then the connection was broken.

Is it because a table of type DECIMAL cannot be read by DolphinDB Python API?

1

There are 1 answers

0
Claire On BEST ANSWER

In version 1.30.21.1, a new parameter protocol has been added to the class session and DBConnectionPool in the Python API. The supported options include PROTOCOL_DDB, PROTOCOL_PICKLE (by default), and PROTOCOL_ARROW.

Currently the DECIMAL type is supported by PROTOCOL_DDB and PROTOCOL_ARROW. Note that the returned result is arrow.Table instead of .DataFrame when you query a table with PROTOCOL_ARROW, so you need to specify protocol=keys.PROTOCOL_DDB in your session:

import dolphindb.settings as keys
s = ddb.session(protocol=keys.PROTOCOL_DDB)

In addition, DECIMAL Array Vector is not supported by all the parameter options currently.

The result is shown as follows:

enter image description here