python - MySQL语句中的语法错误是什么?

标签 python mysql mysql-python

使用 django shell 时:python manage.py shell

import datetime
from django.utils import timezone
DE = datetime.datetime(1970, 1, 1, tzinfo=timezone.utc)
cursor.execute("insert into monitor_regionserver (cluster_id, task_id, name, last_attempt_time, load, numberOfRegions, numberOfRequests, memStoreSizeMB, storefileSizeMB, readRequestsCount, writeRequestsCount, readRequestsCountPerSec, writeRequestsCountPerSec, replication_last_attempt_time, replicationMetrics) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", [30L, 484L, '', DE, 0, 0, 0, 0, 0, 0, 0, 0, 0, DE, ''])

光标命令如下所示(文本换行):

cursor.execute("insert into monitor_regionserver (cluster_id, task_id, name, last_attempt_time, load, numberOfRegions, numberOfRequests, memStoreSizeMB, storefileSizeMB, readRequestsCount, writeRequestsCount, readRequestsCountPerSec, writeRequestsCountPerSec, replication_last_attempt_time, replicationMetrics) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", [30L, 484L, '', DE, 0, 0, 0, 0, 0, 0, 0, 0, 0, DE, ''])

我总是收到错误:

ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'load, numberOfRegions, numberOfRequests, memStoreSizeMB, storefileSizeMB, readRe' at line 1")

我对这个问题感到困惑,有什么想法可以分享吗?

最佳答案

load是mysql中的关键字see here

尝试重命名该列

关于python - MySQL语句中的语法错误是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24011531/

相关文章:

python - 如何划分 2 个 VARCHAR(255) 值并插入到行中(MySQL、Python)

python - 有效的 JSON,但是 "No JSON object could be decoded"

php - 连接到同一网络上另一台电脑上的 mysql 数据库

python - MySQLdb 正在缓存 SELECT 结果?

mysql - 什么是更好的选择? IN 运算符或 EXISTS

mysql - 将 Visual Studio 2013 与 Entity Framework 6 结合使用如何将代码优先与 mySql 数据库结合使用

Python:MySQLdb LOAD DATA INFILE 静默失败

python - django settings.py 不会读取单元测试的环境变量

python - 使用在 windows 上为 linux 创建的 conda env

python - 如何只包含一次js和css