2

I put the dataset into cnosdb this morning and wanna use pandas to find some coefficients, but it looks like the connector can't parse the response so that it prints the response like this:

   area  dv  time
0  area  dv  time
1  area  dv  time
2  area  dv  time

Here is my env.

  • OS: windows-11 home edition, not the WSL
  • Python 3.11.4
    • pandas 2.0.2
    • cnos-connector 0.1.8
  • CnosDB: tag-v2.3.1 4b169315

Here is the minimal commands to re-produce the error, following this page: reference/connector/python.html .

1. Prepare

## write three rows of data
> curl -X POST -u 'root:' ‘http://127.0.0.1:8902/api/v1/write?db=public’ -d 'ds,area=a1 dv=1'
> curl -X POST -u 'root:' ‘http://127.0.0.1:8902/api/v1/write?db=public’ -d 'ds,area=a1 dv=2'
> curl -X POST -u 'root:' ‘http://127.0.0.1:8902/api/v1/write?db=public’ -d 'ds,area=a1 dv=3'
## install the cnos-connector
> pip install cnos-connector
Collecting cnos-connector
  Downloading cnos_connector-0.1.8-py3-none-any.whl (7.6 kB)
Installing collected packages: cnos-connector
Successfully installed cnos-connector-0.1.8
## run python cli
> python
>>> from cnosdb_connector import connect
>>> import pandas as pd
>>> conn = connect(url="http://127.0.0.1:8902/", user="root", password="")

2. Do the query

## Execute the query
>>> resp = pd.read_sql("SELECT * FROM ds", conn)
<stdin>:1: UserWarning: pandas only supports SQLAlchemy connectable (engine/connection) or database string URI or sqlite3 DBAPI2 connection. Other DBAPI2 objects are not tested. Please consider using SQLAlchemy.
## Print the response
>>> print(resp)
   area  dv  time
0  area  dv  time
1  area  dv  time
2  area  dv  time

Responses are all the column-names without any data.

  • Am I using the wrong version of the connector?
  • Am I using the wrong version of the document?

Solved

It's because I am using pandas v2, this connector only works on pandas v1.

Darts
  • 153
  • 5

2 Answers2

2

I cannot reproduce this bug. If this bug continues to appear in your place, please reply me with more details, such as the results of direct query through CnosDB-CLI and the logs of cnosdb, etc.

Subsegment
  • 152
  • 6
  • This problem only appears with lib pandas, the others are all right. What is your query result using pandas? – Darts Jun 29 '23 at 07:12
  • 1
    It's because i am using pandas v2, this connector works on pandas v1 – Darts Jun 29 '23 at 09:56
1

This issue seems to have been solved in cnos-connector 0.1.9

Subsegment
  • 152
  • 6