id为啥没有设置

来源:4-1 存储数据到MySQL

wangyijieonline

2016-09-17 17:25

我这报错了


Wikipedia <---------> https://en.wikipedia.org/wiki/Wikipedia
Traceback (most recent call last):
  File "E:\Demo\Python\Python35\urllib\wikipedia2mysql.py", line 37, in <module>
    cursor.execute(sql,(url.get_text(),"https://en.wikipedia.org"+url["href"]))
  File "D:\Python35\lib\site-packages\pymysql\cursors.py", line 166, in execute
    result = self._query(query)
  File "D:\Python35\lib\site-packages\pymysql\cursors.py", line 322, in _query
    conn.query(q)
  File "D:\Python35\lib\site-packages\pymysql\connections.py", line 835, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "D:\Python35\lib\site-packages\pymysql\connections.py", line 1019, in _read_query_result
    result.read()
  File "D:\Python35\lib\site-packages\pymysql\connections.py", line 1302, in read
    first_packet = self.connection._read_packet()
  File "D:\Python35\lib\site-packages\pymysql\connections.py", line 981, in _read_packet
    packet.check_error()
  File "D:\Python35\lib\site-packages\pymysql\connections.py", line 393, in check_error
    err.raise_mysql_exception(self._data)
  File "D:\Python35\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.InternalError: (1364, "Field 'id' doesn't have a default value")


写回答 关注

4回答

  • 楷格的爸爸
    2017-11-24 16:14:33

    我的不可以,只能手动加上一个id字段,写入循环i=i+1,但写入时出现问题了,求教大家:

    1如何使用自动递增字段的

    2写入时是不是直接忽略这个字段

    3自增字段必须设置成主键吗?

  • Chuihunzhe
    2017-11-10 23:13:45

    嘻嘻额  我的勾勒可以了

  • Kunz
    2017-05-24 16:09:34

    同问,勾选自动递增也没用

  • 猴子哥的故事
    2016-09-17 21:25:08

    你要在新建urls表的时候勾选中下面的“自动递增”才可以

    http://img.mukewang.com/57dd442f00015f4b06990154.jpg

    phoeni...

    我使用的是mysql官方的软件,跟老师的不一样,创建表时勾选了id自增,但是也报“id没有默认值”的错误,怎么回事?

    2017-04-02 00:25:54

    共 1 条回复 >

python遇见数据采集

本教程让你初步掌握Python进行数据采集,创造属于你的价值

59669 学习 · 200 问题

查看课程

相似问题