taos-connector-python
taos-connector-python copied to clipboard
Table name is case sensitive in parameter binding statement - WebSocket client
- TDEngine server version: 3.3.2.0 (
SELECT server_version();
). - Python
taos-ws-py
client version: 0.3.3 (import taosws; print(taosws.__version__)
). - Python version: 3.9.19.
I use the taosws
client and write data with parameter binding. Setting the table name fails when the name includes uppercase letters.
from datetime import datetime, timezone
import taosws
TABLE_NAME = "lowUP"
conn = taosws.connect("taosws://root:taosdata@localhost:6041")
conn.execute("CREATE DATABASE IF NOT EXISTS t0;")
conn.execute("USE t0;")
conn.execute(f"CREATE TABLE {TABLE_NAME} (time TIMESTAMP, val INT);")
print(f'{list(conn.query("SHOW TABLES;")) = }')
# Standard insertion
conn.execute(f"INSERT INTO {TABLE_NAME} VALUES (now(), 0);")
# Select the data
print(f'{list(conn.query(f"SELECT * FROM {TABLE_NAME};")) =}')
# Parameter bound insertion
stmt = conn.statement()
stmt.prepare("INSERT INTO ? VALUES (?, ?);")
stmt.set_tbname(TABLE_NAME) # <-- this line errors
stmt.bind_param(
[
taosws.millis_timestamps_to_column([int(datetime.now(tz=timezone.utc).timestamp() * 1000)]),
taosws.ints_to_column([2]),
]
)
stmt.add_batch()
stmt.execute()
print(f'{list(conn.query(f"SELECT * FROM {TABLE_NAME};")) =}')
Error:
ProgrammingError: [0x2603] Internal error: `Table does not exist`
When TABLE_NAME
is lowercase only, e.g. "low"
, the snippet passes.
I expect it to work since TDEngine table names are case-insensitive:
Names are case insensitive.
https://docs.tdengine.com/reference/taos-sql/limit/#restrictions-of-tablecolumn-names
I found that escaping the table name with `` works:
TABLE_NAME = "`lowUP`"
Still, the current behavior is unexpected.