繁体   English   中英

使用blob值时mysql db插入错误

[英]mysql db insert error when using blob value

使用python adbapi在mysql中的表中插入一行

像insert一样,id是一个int,value是一个blob

db.runQuery("INSERT INTO t (id, blob_value) VALUES (%(id)s, %(blob_value)s)", \
{
    "id" : id,
    "blob_value" : blob_value
}

Traceback: <class '_mysql_exceptions.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 INSERT INTO t (id, blob_value) VALUES (%(id)s, %(blob_value)s)",

而且我认为它可能是一个引用字符 - '在blob_value ,这就是它失败的原因吗?

好的,原因是表名 - “解锁”,这是mysql的关键词。

有人会帮忙如何删除一个名为“unlock”的表吗?

简短的答案:

DROP TABLE `UNLOCK`
SELECT * FROM `UNLOCK`

使用强大的`

只需在表名周围添加反引号:

drop table `unlock`;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM