已有184人关注
《Python从入门到精通》中的疑问
发表在Python图书答疑 2019-09-23 《Python从入门到项目实践》第15章 使用Python操作数据库
是否精华
版块置顶:

我在学习《Python从入门到精通》中的14.3.4中,严格按照书中的代码编写执行后报错:


      

Warning (from warnings module):

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pymysql\cursors.py", line 170

    result = self._query(query)

Warning: (1051, "Unknown table 'mrsoft.books'")

Traceback (most recent call last):

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\conn3.py", line 15, in <module>

    cursor.execute(sql)

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pymysql\cursors.py", line 170, in execute

    result = self._query(query)

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pymysql\cursors.py", line 328, in _query

    conn.query(q)

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pymysql\connections.py", line 517, in query

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

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pymysql\connections.py", line 732, in _read_query_result

    result.read()

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pymysql\connections.py", line 1075, in read

    first_packet = self.connection._read_packet()

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pymysql\connections.py", line 684, in _read_packet

    packet.check_error()

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pymysql\protocol.py", line 220, in check_error

    err.raise_mysql_exception(self._data)

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pymysql\err.py", line 109, in raise_mysql_exception

    raise errorclass(errno, errval)

pymysql.err.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 'data DEFAULT NULL, \n PRIMARY KEY (id)\n ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT ' at line 6")


我用的是Python3.8 和 MySQL8.0 版本,敬请老师答疑,不胜感激!




分享到:
精彩评论 2
andy
学分:2118 LV10
TA的每日心情
继续努力
2017-02-06 23:42:34
2019-09-23
沙发

读者你好:

    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 'data DEFAULT NULL, \n PRIMARY KEY (id)\n ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT ' at line 6"

       提示MySQL语法错误。也有可能是MySQL8都一些语法不再支持了。

        请粘贴一下你写的代码,我们为您查看一下。

           

醉少_1569545372
学分:8 LV1
2019-09-24
板凳
激活以后,百度网盘失效了
首页上一页 1 下一页尾页 2 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照