MariaDB SQL 语法错误括号 ')' for python

2024-09-30 00:41:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用python脚本将一些数据插入到MariaDB中。 当我在控制台中执行以下操作时,它工作得非常好。在

INSERT INTO `Failure` (`faillure_id`, `testrun_id`, `failed_at`, `log_path`, `node`) 
         VALUES   (2, 1, 'STEP8:RUN:RC=1', '/var/fail_logs','NodeA')

显示查询ok。我可以看到表格被填充。没问题。在

但是,当我使用python执行相同的SQL查询时,我会遇到一些错误。 这是我的密码

^{pr2}$

这将产生以下错误

check the manual that corresponds to your MariaDB server version for the right syntax to use near '),

有人能帮我弄清楚错误是从哪里来的吗。在


Tags: theto数据脚本logidfailure错误
1条回答
网友
1楼 · 发布于 2024-09-30 00:41:28

为了解决这个问题,我构建了这样的查询字符串

sql_query = "INSERT INTO `Failure` (`testrun_id`, `failed_at`, `log_path`, `node`) VALUES " + "( '" + str(testrun_id) + "', '" + str(failed_at) + "', '"+ log_path + "', '" + node + "')"
cursor.execute(sql_query)

效率不高,但现在能做。在

相关问题 更多 >

    热门问题