taosdata / taos-connector-python

TDengine connector for Python
https://www.taosdata.com/cn/documentation/connector#python
MIT License
46 stars 13 forks source link

window下漏查数据 #237

Closed Game0fLife closed 9 months ago

Game0fLife commented 9 months ago

Issues

taos版本

root@8777afda5dc9:~# taos
Welcome to the TDengine Command Line Interface, Client Version:3.2.1.0
Copyright (c) 2023 by TDengine, all rights reserved.

  ********************************  Tab Completion  ************************************
  *   The TDengine CLI supports tab completion for a variety of items,                 *
  *   including database names, table names, function names and keywords.              *
  *   The full list of shortcut keys is as follows:                                    *
  *    [ TAB ]        ......  complete the current word                                *
  *                   ......  if used on a blank line, display all supported commands  *
  *    [ Ctrl + A ]   ......  move cursor to the st[A]rt of the line                   *
  *    [ Ctrl + E ]   ......  move cursor to the [E]nd of the line                     *
  *    [ Ctrl + W ]   ......  move cursor to the middle of the line                    *
  *    [ Ctrl + L ]   ......  clear the entire screen                                  *
  *    [ Ctrl + K ]   ......  clear the screen after the cursor                        *
  *    [ Ctrl + U ]   ......  clear the screen before the cursor                       *
  **************************************************************************************

Server is Community Edition.

taos> 

taos CLI:

SELECT * FROM test2 where  ts > '2023-06-01 00:00:00' and ts < '2023-06-30 23:59:59';
ts            |         test_1          |       
================================================================================
 2023-06-30 23:59:30.000 |            3.3378906 | 

简化后,原表50列数据

taos linux(ubuntu 20.04):

pandas                   1.5.3   
SQLAlchemy               2.0.23 
import pandas
from sqlalchemy import create_engine, text

engine = create_engine("taos://root:taosdata@127.0.0.1:6030/db")
conn = engine.connect()
df = pandas.read_sql(text("SELECT * FROM test2 where  ts > '2023-06-01 00:00:00' and ts < '2023-06-30 23:59:59'"), conn)
conn.close()

# print index
print(df.index)
# print data type  of element in ts column
print(type(df.ts[0]))
print(df.head(3))
RangeIndex(start=0, stop=1, step=1)
<class 'pandas._libs.tslibs.timestamps.Timestamp'>
                   ts       test_1      ...
0 2023-06-30 23:59:30  3.337891     ...
[1 rows x 53 columns]

taos windows

TDengine-client-3.2.1.0-Windows-x64.exe (9.3 M)
sqlalchemy pip 下载,应该是最新版本
import pandas
from sqlalchemy import create_engine, text

engine = create_engine("taos://root:taosdata@127.0.0.1:6030/db")
conn = engine.connect()
df = pandas.read_sql(text("SELECT * FROM test2 where  ts > '2023-06-01 00:00:00' and ts < '2023-06-30 23:59:59'"), conn)
conn.close()

# print index
print(df.index)
# print data type  of element in ts column
print(type(df.ts[0]))
print(df.head(3))

# 两种方式都已尝试
 #self.conndf = create_engine("taos://root:taosdata@127.0.0.1:6030/db").connect()
        # self.conn = create_engine("taos://root:taosdata@localhost:6030/db").connect()
        # self.conn = taos.connect(host="127.0.0.1", user="root",
        #                                      password="taosdata",
        #                                      database="db",
        #                                      port=6030,
        #                                      config="/etc/taos",  # for windows the default value is C:\TDengine\cfg
        #                                      timezone="Asia/Shanghai")  # default your host's timezone
Connected to pydev debugger (build 201.6668.113)
SELECT * FROM test2 where ts > '2023-06-30 23:55:00' and ts < '2023-06-30 23:59:59'
Empty DataFrame
Columns: [ts, test_1,...]
Index: []

Process finished with exit code 0
Game0fLife commented 9 months ago

时区配置的问题,更改数据库时区后原生连接正常