Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

taos的execute语句占位符是对应类型占位还是%s可以为所有类型占位? #27482

Open
myprospection opened this issue Aug 27, 2024 · 4 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@myprospection
Copy link

cursor=conn.cursor()
placeholder=','.join(['%s']*len(data.dtype.names))
for row in data:
for i,value in enumerate(row):
if isinstance(value,np.datetime64):
row[i]=datetime64_to_datetime(value)

	row = tuple(row)
	cursor.execute(f"INSERT INTO {table}({','.join(data.dtype.names)}) VALUES({placeholder})",row)

我在网上看到%s占位符,然后execute时把实际数值放进去我实际操作的时候报错了
错误信息:
Traceback (most recent call last):
File "load_into_database.py", line 27, in
narray_to_taos('127.0.0.1','root','123456','test',6041,'mytest',data)
File "load_into_database.py", line 20, in narray_to_taos
cursor.execute(f"INSERT INTO {table}({','.join(data.dtype.names)}) VALUES({placeholder})",row)
taosws.OperationalError: [0x0216] Internal error: syntax error near '%s,%s,%s)' (invalid data or symbol)

@myprospection myprospection added help wanted Extra attention is needed question Further information is requested labels Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants
@myprospection and others