taosdata / TDengine

TDengine is an open source, high-performance, cloud native time-series database optimized for Internet of Things (IoT), Connected Cars, Industrial IoT and DevOps.

Home Page:https://tdengine.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In Linux system deployment, inserting TDengine database to save, but running the same code on Windows is successful

youth123-c opened this issue · comments

import taosws

class TDengineDatabase:
    def __init__(self, host, port,user, password, db):
        self.conn = taosws.connect(
            host=host,
            port=port,
            user=user,
            password=password,
            dbname=db
        )
        self.cursor = self.conn.cursor()

    def execute_sql(self, sql):
        try:
            self.cursor.execute(sql)
        except Exception as e:
            print(f"Error executing SQL: {e}")

    def query_data(self, sql):
        self.cursor.execute(sql)
        return self.cursor.fetchall()

    def close(self):
        self.cursor.close()
        self.conn.close()


def use_TDengine():
    return TDengineDatabase(
    host=TDhost,
    port=TDport,
    user=TDuser,
    password=TDpassword,
    db=db
    )

def insert():
   try:
     db = use_TDengine()
     sql = f"INSERT INTO ev.C_110 (ts,value1,value2) USING ev.stbdata TAGS('t_1','1','I_EDSPump_Meas') VALUES ('2024-06-11 01:05:48.368685',0.7428830509966069, -16.25)"
     db.execute_sql(sql)
   except Exception as e:
     print(e)

Executing in Linux system will get stuck in db. execute_sql (SQL), and then it will report "code 400, message Bad request version ('_ \ x13_ ')"
"\ x16 \ x03 \ x01 \ x00_ \ x01 \ x00 \ x00_ \ x03 \ x03_ \ x86zv_l5 \ x111__ # _ (: > \ x032 \ x9f ^ _ \ x86 \ x06_O3 _ \ x19 \ x95% Q/\ x96_ \ x88_XJ+\ x93 \ x060_ \ x16a_ \ x1a [* 2 \ x9f \ x00>\ x00&+/, 0 _____ \ x09 \ x13_" -400 "
But using 'query_data' to query in Linux is not a problem