【发布时间】:2021-08-12 08:25:51
【问题描述】:
我正在 python 代码中执行 SQL 查询。此查询在 SQLite 的 DB 浏览器中使用时可以正常工作,当我尝试在 python 中使用时,它显示如下错误:
Error: unsupported format character ',' (0x2c) at index 286")) in python .
这里查询:
query = "Select * from ( select detection_class, detection_class_id, matched_alert_id, stream_id, track_id, detection_time, frame_id "\
" from matched_alert "\
" where stream_id = '863b1675269e4600ab52a2cf0c418edc' "\
" ) "\
" where (SELECT ',' || detection_class || ',' FROM alerts WHERE alert_id=4 ) LIKE '%,' || detection_class || ',%' "
执行如下:
place_holders = [stream_id, alert_id]
try:
with connection.cursor() as cursor:
cursor.execute(query, place_holders)
rows = cursor.fetchall()
我尝试了相关问题的各种答案,但没有奏效。 我该如何解决这个问题,有人建议我吗?
【问题讨论】: