{Mysql2 :: Error}使用mysql2时,列数与第1行的值计数不匹配

时间:2016-01-05 04:41:24

标签: mysql ruby mysql2

这是我的full sql,我尝试按照代码并提出Column count doesn't match value count at row 1 when use mysql2

conf = {adapter: "mysql2", host: "localhost", username: "root", password: "root", database: 'ro_article_prod', port: 3306, encoding: 'utf8mb4', flags: (Mysql2::Client::FOUND_ROWS | Mysql2::Client::MULTI_STATEMENTS), encoding: 'utf8', checkout_timeout: 1.day, connect_timeout: 1.hour, reconnect: true, pool: 2000}
m = Mysql2::Client.new(conf)
m.query(RoFile.read("chk/val.sql"));
m.abandon_results!

但是当我在mysql shell中运行以下代码时,它可以工作而不会引发任何错误

insert articles (title, url, ctn, ctn_md5, created_at, updated_at) values("Amy (Character)  - Quotes", "http:/www.imdb.com/character/ch0052152/quotes", "", "", "2016-01-05 07:12:55", "2016-01-05 07:12:55");
insert articles (title, url, ctn, ctn_md5, created_at, updated_at) values("Amy (Character)", "http:/www.imdb.com/character/ch0052152/maindetails", "", "", "2016-01-05 07:12:55", "2016-01-05 07:12:55");
insert articles (title, url, ctn, ctn_md5, created_at, updated_at) values("Amy (Character)  - Filmography by type", "http:/www.imdb.com/character/ch0052152/filmotype", "", "", "2016-01-05 07:12:55", "2016-01-05 07:12:55");

1 个答案:

答案 0 :(得分:1)

在您链接到的完整SQL中,所有行都有六列,但其中一列有五个值。这是不正确的:

insert articles (title, url, ctn, ctn_md5, created_at, updated_at) values("Trudy Chelgren (Character)  - Filmography by rating", "http:/www.imdb.com/character/ch0052168/filmorate", "", "2016-01-05 07:12:55", "2016-01-05 07:12:55");