python 插入mysql报错

图片描述

insert into oppo_feeds_stat_ad_img_report (account_id,ad_id,ad_name,img_url,created_at,updated_at)values(1000018156,257389,'大图一男龄一0213一农村','http://adsfs.oppomobile.com/res/mat_pic/201802/13/1000018156_1518516915.jpg','2018-02-13','2018-02-13');

Traceback (most recent call last):

File "/home/stephen/loading/Oppo/oppo.py", line 718, in <module>

oppo.login_in()

File "/home/stephen/loading/Oppo/oppo.py", line 55, in login_in

self.Promotion_manage(manage_page_response.encode("utf-8"),login_token_headers)

File "/home/stephen/loading/Oppo/oppo.py", line 282, in Promotion_manage

self.report_list(manage_page_data[i], manage_page_data[i - 10 + 2 - 1],login_token_headers)

File "/home/stephen/loading/Oppo/oppo.py", line 521, in report_list

self.cursor.execute(sql1)

File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 165, in execute

result = self._query(query)

File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 321, in _query

conn.query(q)

File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 860, in query

self._affected_rows = self._read_query_result(unbuffered=unbuffered)

File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1061, in _read_query_result

result.read()

File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1349, in read

first_packet = self.connection._read_packet()

File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1018, in _read_packet

packet.check_error()

File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 384, in check_error

err.raise_mysql_exception(self._data)

File "/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 107, in raise_mysql_exception

raise errorclass(errno, errval)

pymysql.err.InternalError: (1136, u"Column count doesn't match value count at row 1")

insert into oppo_feeds_stat_ad_img_report (account_id,ad_id,ad_name,img_url,created_at,updated_at)values(1000018156,257389,'大图一男龄一0213一农村','http://adsfs.oppomobile.com/r...

','2018-02-13','2018-02-13');

回答:

在插入数据时,插入的字段个数跟数据库表字段个数不一致,就会报这个错误。

insert into oppo_feeds_stat_ad_img_report (account_id, ad_id,ad_name, img_url, created_at, updated_at)values(1000018156, 257389, '大图一男龄一0213一农村','http://adsfs.oppomobile.com/r...

','2018-02-13','2018-02-13');

经测试,你的字段名之间的逗号有中文字符。
请确保字段名之间的逗号,以及字段值之间的逗号都要是英文字符。

回答:

File "/home/stephen/loading/Oppo/oppo.py", line 718, in <module>
看看这行代码,错误报得很清楚:Column count doesn't match value count at row 1
count列没有对应count的值

看看你的代码吧, 没有代码很难猜(如果有列命名成count也不太合适)

以上是 python 插入mysql报错 的全部内容, 来源链接: utcz.com/a/161726.html

回到顶部